具体信息如下:
RES是1.6G
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
28527 root 20 0 12.1g 1.6g 13m S 0.0 5.0 0:52.19 java
但是used:堆用了262M, concurrent mark-sweep generation用了48M,interned String占了250多M
Attaching to process ID 28527, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.51-b03
using parallel threads in the new generation.
using thread-local object allocation.
Concurrent Mark-Sweep GC
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 8589934592 (8192.0MB)
NewSize = 4294967296 (4096.0MB)
MaxNewSize = 4294967296 (4096.0MB)
OldSize = 4294967296 (4096.0MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 21807104 (20.796875MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 17592186044415 MB
G1HeapRegionSize = 0 (0.0MB)
Heap Usage:
New Generation (Eden + 1 Survivor Space):
capacity = 3865509888 (3686.4375MB)
used = 274884512 (262.1502990722656MB)
free = 3590625376 (3424.2872009277344MB)
7.1112096454169% used
Eden Space:
capacity = 3436052480 (3276.875MB)
used = 274884512 (262.1502990722656MB)
free = 3161167968 (3014.7247009277344MB)
8.000009126752337% used
From Space:
capacity = 429457408 (409.5625MB)
used = 0 (0.0MB)
free = 429457408 (409.5625MB)
0.0% used
To Space:
capacity = 429457408 (409.5625MB)
used = 0 (0.0MB)
free = 429457408 (409.5625MB)
0.0% used
concurrent mark-sweep generation:
capacity = 4294967296 (4096.0MB)
used = 50954384 (48.59388732910156MB)
free = 4244012912 (4047.4061126708984MB)
1.1863742023706436% used
22283 interned Strings occupying 2737728 bytes.
用top中查看RES是操作系统角度看jvm的内存占用。
用jmap查看的堆内存,是用jvm的角度看jvm内部程序的内存占用。
存在差异是因为jvm有一些共享库和共享内存,被操作系统计入RES中,但未被jvm计入。