update vmtool command tutorials

This commit is contained in:
hengyunabc
2021-05-14 01:00:50 +08:00
parent 4c573990c3
commit 5fbb943c37
8 changed files with 33 additions and 26 deletions
@@ -3,9 +3,8 @@
### 指定 classloader name
```bash
vmtool --action getInstances --classLoaderClass org.springframework.boot.loader.LaunchedURLClassLoader --className org.springframework.context.ApplicationContext
```
`vmtool --action getInstances --classLoaderClass org.springframework.boot.loader.LaunchedURLClassLoader --className org.springframework.context.ApplicationContext`{{execute T2}}
### 指定 classloader hash
@@ -1,6 +1,7 @@
### 强制GC
```bash
vmtool --action forceGc
```
`vmtool --action forceGc`{{execute T2}}
@@ -2,6 +2,8 @@
### 查找spring context
`vmtool --action getInstances --className org.springframework.context.ApplicationContext `{{execute T2}}
```bash
$ vmtool --action getInstances --className org.springframework.context.ApplicationContext
@ApplicationContext[][
@@ -15,9 +17,7 @@ $ vmtool --action getInstances --className org.springframework.context.Applicati
> 通过 `-x`/`--expand` 参数可以指定结果的展开层次,默认值是1。
```bash
vmtool --action getInstances -c 19469ea2 --className org.springframework.context.ApplicationContext -x 2
```
`vmtool --action getInstances --className org.springframework.context.ApplicationContext -x 2`{{execute T2}}
### 执行表达式
@@ -25,12 +25,15 @@ vmtool --action getInstances -c 19469ea2 --className org.springframework.context
查找所有的spring beans名字:
```bash
vmtool --action getInstances --className org.springframework.context.ApplicationContext --express 'instances[0].getBeanDefinitionNames()'
```
`vmtool --action getInstances --className org.springframework.context.ApplicationContext --express 'instances[0].getBeanDefinitionNames()'`{{execute T2}}
调用`userController.findUserById(1)`函数:
`vmtool --action getInstances --className org.springframework.context.ApplicationContext --express 'instances[0].getBean("userController").findUserById(1)'`{{execute T2}}
```
$ vmtool --action getInstances --className org.springframework.context.ApplicationContext --express 'instances[0].getBean("userController").findUserById(1)'
@User[
@@ -41,6 +44,9 @@ $ vmtool --action getInstances --className org.springframework.context.Applicati
### 查找所有的spring mapping对象
`vmtool --action getInstances --className org.springframework.web.servlet.HandlerMapping`{{execute T2}}
```bash
$ vmtool --action getInstances --className org.springframework.web.servlet.HandlerMapping
@HandlerMapping[][
@@ -5,6 +5,8 @@
### 查找jvm里的字符串对象
`vmtool --action getInstances --className java.lang.String`{{execute T2}}
```bash
$ vmtool --action getInstances --className java.lang.String
@String[][
@@ -1,9 +1,6 @@
### Specify classloader name
```bash
vmtool --action getInstances --classLoaderClass org.springframework.boot.loader.LaunchedURLClassLoader --className org.springframework.context.ApplicationContext
```
`vmtool --action getInstances --classLoaderClass org.springframework.boot.loader.LaunchedURLClassLoader --className org.springframework.context.ApplicationContext`{{execute T2}}
### Specify classloader hash
@@ -1,6 +1,4 @@
### forceGc
```bash
vmtool --action forceGc
```
`vmtool --action forceGc`{{execute T2}}
@@ -2,6 +2,8 @@ Next, use the `vmtool` command to find objects in spring.
### Find spring context
`vmtool --action getInstances --className org.springframework.context.ApplicationContext `{{execute T2}}
```bash
$ vmtool --action getInstances --className org.springframework.context.ApplicationContext
@ApplicationContext[][
@@ -15,9 +17,7 @@ $ vmtool --action getInstances --className org.springframework.context.Applicati
> The expansion level of the result can be specified by the `-x`/`--expand` parameter, the default value is 1.
```bash
vmtool --action getInstances -c 19469ea2 --className org.springframework.context.ApplicationContext -x 2
```
`vmtool --action getInstances --className org.springframework.context.ApplicationContext -x 2`{{execute T2}}
### Execute expression
@@ -25,11 +25,11 @@ vmtool --action getInstances -c 19469ea2 --className org.springframework.context
Find the names of all spring beans:
```bash
vmtool --action getInstances --className org.springframework.context.ApplicationContext --express'instances[0].getBeanDefinitionNames()'
```
`vmtool --action getInstances --className org.springframework.context.ApplicationContext --express 'instances[0].getBeanDefinitionNames()'`{{execute T2}}
Call the `userController.findUserById(1)` function:
Call the `userController.findUserById(1)` method:
`vmtool --action getInstances --className org.springframework.context.ApplicationContext --express 'instances[0].getBean("userController").findUserById(1)'`{{execute T2}}
```
$ vmtool --action getInstances --className org.springframework.context.ApplicationContext --express'instances[0].getBean("userController").findUserById(1)'
@@ -41,6 +41,8 @@ $ vmtool --action getInstances --className org.springframework.context.Applicati
### Find all spring mapping objects
`vmtool --action getInstances --className org.springframework.web.servlet.HandlerMapping`{{execute T2}}
```bash
$ vmtool --action getInstances --className org.springframework.web.servlet.HandlerMapping
@HandlerMapping[][
@@ -6,6 +6,8 @@ Use the `vmtool` command to find the jvm object.
### Find string objects in jvm
`vmtool --action getInstances --className java.lang.String`{{execute T2}}
```bash
$ vmtool --action getInstances --className java.lang.String
@String[][