forked from oracle/graal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent-dumpheap.test
More file actions
12 lines (12 loc) · 868 Bytes
/
agent-dumpheap.test
File metadata and controls
12 lines (12 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
> export CP=${JAVA_HOME}/lib/visualvm/visualvm/modules/org-graalvm-visualvm-lib-jfluid.jar:${JAVA_HOME}/lib/visualvm/visualvm/modules/org-graalvm-visualvm-lib-profiler-oql.jar:.
>[0] javac -cp $CP HeapQuery.java
#> export TMP_DIR=/tmp
>[??] rm -rf ${TMP_DIR}/sample.hprof*
>[7?] js --insight=agent-dump.js --heap.dump=${TMP_DIR}/sample.hprof agent-fib.js
# a JavaScript heap has been generated
>[0] java -cp $CP HeapQuery ${TMP_DIR}/sample.hprof -e 'heap.forEachClass((c) => c.name.startsWith("frame:") && print(c.name))'
frame:minusTwo
>[0] java -cp $CP HeapQuery ${TMP_DIR}/sample.hprof -e 'let arr = []; heap.forEachObject((frame) => { for (let p in frame) { arr.push(p); } }, "frame:minusTwo"); arr.sort(); print(arr);'
["n", "this"]
>[0] java -cp $CP HeapQuery ${TMP_DIR}/sample.hprof -e 'heap.forEachObject((frame) => print(frame.n.value), "frame:minusTwo");'
2