import{_ as i,o as c,c as r,a as e,b as n,w as l,e as s,d,r as o}from"./app.391b0e4e.js";const p={},u=e("h1",{id:"vmtool",tabindex:"-1"},[e("a",{class:"header-anchor",href:"#vmtool","aria-hidden":"true"},"#"),s(" vmtool")],-1),h=e("div",{class:"custom-container tip"},[e("p",{class:"custom-container-title"},"TIP"),e("p",null,"@since 3.5.1")],-1),m={href:"https://arthas.aliyun.com/doc/arthas-tutorials.html?language=en&id=command-vmtool",target:"_blank",rel:"noopener noreferrer"},v=e("code",null,"vmtool",-1),b=s(" online tutorial"),g=e("p",null,[e("code",null,"vmtool"),s(" uses the "),e("code",null,"JVMTI"),s(" to support "),e("code",null,"getInstances"),s(" in jvm and "),e("code",null,"forceGc"),s(".")],-1),f={href:"https://docs.oracle.com/javase/8/docs/platform/jvmti/jvmti.html",target:"_blank",rel:"noopener noreferrer"},k=s("JVM Tool Interface"),x=d(`
$ vmtool --action getInstances --className java.lang.String --limit 10
@String[][
@String[com/taobao/arthas/core/shell/session/Session],
@String[com.taobao.arthas.core.shell.session.Session],
@String[com/taobao/arthas/core/shell/session/Session],
@String[com/taobao/arthas/core/shell/session/Session],
@String[com/taobao/arthas/core/shell/session/Session.class],
@String[com/taobao/arthas/core/shell/session/Session.class],
@String[com/taobao/arthas/core/shell/session/Session.class],
@String[com/],
@String[java/util/concurrent/ConcurrentHashMap$ValueIterator],
@String[java/util/concurrent/locks/LockSupport],
]
TIP
Through the --limit
parameter, you can limit the number of return values to avoid pressure on the JVM when obtaining large data. The default value of limit is 10.
vmtool --action getInstances --classLoaderClass org.springframework.boot.loader.LaunchedURLClassLoader --className org.springframework.context.ApplicationContext
The classloader that loads the class can be found through the sc
command.
$ sc -d org.springframework.context.ApplicationContext
class-info org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext
code-source file:/private/tmp/demo-arthas-spring-boot.jar!/BOOT-INF/lib/spring-boot-1.5.13.RELEASE.jar!/
name org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext
...
class-loader +-org.springframework.boot.loader.LaunchedURLClassLoader@19469ea2
+-sun.misc.Launcher$AppClassLoader@75b84c92
+-sun.misc.Launcher$ExtClassLoader@4f023edb
classLoaderHash 19469ea2
Then use the -c
/--classloader
parameter to specify:
vmtool --action getInstances -c 19469ea2 --className org.springframework.context.ApplicationContext
TIP
The return result of the getInstances
action is bound to the instances
variable, which is an array.
The expansion level of the result can be specified by the -x
/--expand
parameter, the default value is 1.
vmtool --action getInstances -c 19469ea2 --className org.springframework.context.ApplicationContext -x 2
TIP
The return result of the getInstances
action is bound to the instances
variable, which is an array. The specified expression can be executed through the --express
parameter.
vmtool --action getInstances --classLoaderClass org.springframework.boot.loader.LaunchedURLClassLoader --className org.springframework.context.ApplicationContext --express'instances[0].getBeanDefinitionNames()'
vmtool --action forceGc