jmap工具查看堆内存
jmap:全称JVM Memory Map
是一个可以输出所有内存中对象的工具,可以将JVM中的heap(堆),以二进制输出成文本,打印出Java进程对应的内存
找到pid
jmap -heap 19792
Attaching to process ID 19792, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.161-b12using thread-local object allocation.
Parallel GC with 10 thread(s)Heap Configuration:MinHeapFreeRatio = 0 ——>最小堆开放比率MaxHeapFreeRatio = 100 ——>最大堆开放比率MaxHeapSize = 8537505792 (8142.0MB) ——>新生代大小NewSize = 178257920 (170.0MB) ——>最大新生代大小MaxNewSize = 2845835264 (2714.0MB) ——>年老代大小OldSize = 356515840 (340.0MB) ——>最大年老代大小NewRatio = 2 ——>新生代比率SurvivorRatio = 8 ——>存活比率MetaspaceSize = 21807104 (20.796875MB) ——>元空间大小CompressedClassSpaceSize = 1073741824 (1024.0MB) ——>压缩类空间大小MaxMetaspaceSize = 17592186044415 MB ——>最大元空间大小G1HeapRegionSize = 0 (0.0MB) ——>G1堆区域大小Heap Usage:
PS Young Generation
Eden Space: ————>Eden空间capacity = 715128832 (682.0MB) ——>空间大小used = 552720928 (527.1157531738281MB) ——>使用free = 162407904 (154.88424682617188MB) ——>剩余77.28969987886043% used ——>比率
From Space: ————>From空间capacity = 30408704 (29.0MB) ——>空间大小used = 30395408 (28.987319946289062MB) ——>使用free = 13296 (0.0126800537109375MB) ——>剩余99.95627567685884% used ——>比率
To Space: ————>To空间capacity = 45088768 (43.0MB) ——>空间大小used = 0 (0.0MB) ——>使用free = 45088768 (43.0MB) ——>剩余0.0% used ——>比率
PS Old Generation ————>年老代capacity = 282066944 (269.0MB) ——>空间大小used = 84960168 (81.02433013916016MB) ——>使用free = 197106776 (187.97566986083984MB) ——>剩余30.1205688249666% used ——>比率42326 interned Strings occupying 4345832 bytes.
生成dump文件,jmap -dump:
使用jhat分析dump.dat文件 ,如果Dump文件太大,可能需要加上-J-Xmx512m这种参数指定最大堆内存,即jhat -J-Xmx512m -port 9998 /tmp/dump.dat
打开页面