arthas.VmToolMXBean Maven / Gradle / Ivy
package arthas;
/**
* VmTool interface for JMX server. How to register VmTool MBean:
*
*
* {@code
* ManagementFactory.getPlatformMBeanServer().registerMBean(
* VmTool.getInstance(),
* new ObjectName("arthas:type=VmTool")
* );
* }
*
* @author hengyunabc 2021-04-26
*/
public interface VmToolMXBean {
/**
* https://docs.oracle.com/javase/8/docs/platform/jvmti/jvmti.html#ForceGarbageCollection
*/
public void forceGc();
/**
* 打断指定线程
*
* @param threadId 线程ID
*/
void interruptSpecialThread(int threadId);
public T[] getInstances(Class klass);
/**
* 获取某个class在jvm中当前所有存活实例
* @param
* @param klass
* @param limit 如果小于 0 ,则不限制
* @return
*/
public T[] getInstances(Class klass, int limit);
/**
* 统计某个class在jvm中当前所有存活实例的总占用内存,单位:Byte
*/
public long sumInstanceSize(Class> klass);
/**
* 获取某个实例的占用内存,单位:Byte
*/
public long getInstanceSize(Object instance);
/**
* 统计某个class在jvm中当前所有存活实例的总个数
*/
public long countInstances(Class> klass);
/**
* 获取所有已加载的类
*/
public Class>[] getAllLoadedClasses();
}