Java查看Old代对象具体信息

(1)开启 GC 日志

java -XX:+PrintGCDetails -XX:+HeapDumpBeforeFullGC -XX:+PrintHeapAtGC

得如如下类似日志:

[PSYoungGen: 611840K->992K(612352K)] 1260846K->650606K(1308672K), 0.0047655 secs] [Times: user=0.03 sys=0.00, real=0.01 secs]
Heap after GC invocations=30667 (full 91):
PSYoungGen total 612352K, used 992K [0x00000000da800000, 0x0000000100000000, 0x0000000100000000)
eden space 610816K, 0% used [0x00000000da800000,0x00000000da800000,0x00000000ffc80000)
from space 1536K, 64% used [0x00000000ffc80000,0x00000000ffd78000,0x00000000ffe00000)
to space 1536K, 0% used [0x00000000ffe80000,0x00000000ffe80000,0x0000000100000000)
ParOldGen total 696320K, used 649614K [0x00000000b0000000, 0x00000000da800000, 0x00000000da800000)
object space 696320K, 93% used [0x00000000b0000000,0x00000000d7a63bf8,0x00000000da800000)
Metaspace used 69066K, capacity 70738K, committed 71936K, reserved 1114112K
class space used 7654K, capacity 8001K, committed 8192K, reserved 1048576K
}

可以看到 ParOldGen 对象的内存地址为 0x00000000b0000000,0x00000000d7a63bf8,0x00000000da800000
0x00000000b0000000 表示是 OldGen 的起始地址
0x00000000d7a63bf8 表示是使用到的地址. b0000000 ~ d7a63bf8
0x00000000da800000 表示 OldGen 的结束地址

(2)Dump 内存快照:

jmap -dump:format=b,file=/tmp/heap.hprof PID

(3)打开 MAT

开启选项(默认已勾选)

 

 

(4)导入刚才生成的内存快照文件, 打开 OQL 查询, 输入

SELECT * FROM INSTANCEOF java.lang.Object t WHERE (toHex(t.@objectAddress) >= "0xb0000000" AND toHex(t.@objectAddress) <= "0xd6b7fb08")

 

 



 

转自:

https://blog.csdn.net/weixin_33345728/article/details/114546555?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~aggregatepage~first_rank_ecpm_v1~rank_v31_ecpm-1-114546555.pc_agg_new_rank&utm_term=mat%E6%80%8E%E4%B9%88%E6%9F%A5%E7%9C%8B%E8%80%81%E5%B9%B4%E4%BB%A3%E5%AF%B9%E8%B1%A1&spm=1000.2123.3001.4430

 

posted @ 2022-02-25 21:33  ck_2016  Views(947)  Comments(0Edit  收藏  举报