使用jhat工具可以用于分析Java应用程序的堆快照内容。
jmap 产生堆快照,如:
C:\Users\cmcc>jmap -dump:format=b,file=C:\Users\cmcc\Desktop\heap.hprof 1304
Dumping heap to C:\Users\cmcc\Desktop\heap.hprof ...
Heap dump file created
之后用jhat查看该堆快照信息,即 ,之后用浏览器打开查看。 http://localhost:7000/
C:\Users\cmcc>jhat C:\Users\cmcc\Desktop\heap.hprof
Reading from C:\Users\cmcc\Desktop\heap.hprof...
Dump file created Sat Aug 31 22:28:00 CST 2019
Snapshot read, resolving...
Resolving 351076 objects...
Chasing references, expect 70 dots.............................................
........................
Eliminating duplicate references...............................................
......................
Snapshot resolved.
Started HTTP server on port 7000
Server is ready.
也可以查下OQL查下界面:
如可查下当前java程序中所有java.io.File对象的路径:
select file.path.value.toString() from java.io.File file