1.查询tomcat的pid
netstat -anp|grep 端口号
2.jmap -heap pid
jmap -heap 29170
输出
Attaching to process ID 29170, please wait... Debugger attached successfully. Server compiler detected. JVM version is 24.79-b02 using thread-local object allocation. Parallel GC with 10 thread(s) Heap Configuration: MinHeapFreeRatio = 0 MaxHeapFreeRatio = 100 MaxHeapSize = 1073741824 (1024.0MB) NewSize = 1048576 (1.0MB) MaxNewSize = 4294901760 (4095.9375MB) OldSize = 4194304 (4.0MB) NewRatio = 2 SurvivorRatio = 8 PermSize = 16777216 (16.0MB) MaxPermSize = 67108864 (64.0MB) G1HeapRegionSize = 0 (0.0MB) Heap Usage: PS Young Generation Eden Space: capacity = 157286400 (150.0MB) used = 156270504 (149.03116607666016MB) free = 1015896 (0.9688339233398438MB) 99.35411071777344% used From Space: capacity = 63176704 (60.25MB) used = 3237744 (3.0877532958984375MB) free = 59938960 (57.16224670410156MB) 5.124901735931017% used To Space: capacity = 71303168 (68.0MB) used = 0 (0.0MB) free = 71303168 (68.0MB) 0.0% used PS Old Generation capacity = 195821568 (186.75MB) used = 110981208 (105.83992767333984MB) free = 84840360 (80.91007232666016MB) 56.67466006604543% used PS Perm Generation capacity = 67108864 (64.0MB) used = 62198104 (59.316734313964844MB) free = 4910760 (4.683265686035156MB) 92.68239736557007% used 34399 interned Strings occupying 3429440 bytes.
其中MaxHeapSize就是堆内存大小