VisualVM 中的 OQL 语句查询
VisualVM OQL About 2,048 words语法
select <JavaScript expression to select>
[ from [instanceof] <class name> <identifier>
[ where <JavaScript boolean expression to filter> ] ]
注意
VisualVM
中的OQL
语法与MAT
中的OQL
语法不兼容。
select
、from
等关键字必须小写,且结尾不加;
封号。
示例代码
package com.example.test;
public class OQLDemo {
public static Map<String, String> mapVar = new HashMap<>();
public static List<String> listVar = new ArrayList<>();
public static String[] arrVar = {"xxx", "yyy", "zzz"};
public static ThreadPoolExecutor executorVar = new ThreadPoolExecutor(2,
30,
100L,
TimeUnit.SECONDS,
new LinkedBlockingQueue<>(3),
Executors.defaultThreadFactory(),
new ThreadPoolExecutor.CallerRunsPolicy());
static {
for (int i = 0; i < 20; i++) {
mapVar.put("key" + i, "value" + i);
listVar.add("list" + i);
int finalI = i;
executorVar.execute(() -> {
String s = "this is executor" + finalI;
new OQLDemo();
LockSupport.park();
});
}
}
public String abc = "aaabbbccc";
public static void main(String[] args) {
LockSupport.park();
}
}
查看静态变量
statics
表示静态变量
select heap.findClass("com.example.test.OQLDemo").statics.listVar
所有静态变量
select map(heap.findClass("com.example.test.OQLDemo").statics, "index + '=' + toHtml(it)")
查询固定字符串
等于aaabbbccc
字符串。·
select s from java.lang.String s where s.toString() == 'aaabbbccc'
查询包含字符串
包含bbb
字符串。
select s from java.lang.String s where s.toString().indexOf("bbb") != -1
遍历 Map 对象
select map(filter(heap.findObject("0x85a85cb0"), 'it != null && it.key != null && it.value != null'),
function (it) {
var res = it.key.toString() + ' = ' + it.value.toString();
return res;
});
更多用法
Views: 3,718 · Posted: 2021-08-01
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...