物理内存占用
Committed & Reserved & RSS
Committed
Address ranges that have been mapped with something other than
PROT_NONE
. They may or may not be backed by physical or swap due to lazy allocation and paging.
已分配的内存,但不一定占用物理内存或swap
Reserved
The total address range that has been pre-mapped via
mmap
for a particular memory pool.
和Committed
的区别在于Reserved
包含PROT_NONE
(一定不占用物理内存)的映射
RSS
Resident set size, the non-swapped physical memory that a task has used (in kiloBytes)
实际占用的物理内存(不包括已Committed但未分配的,以及swap-out的)
参考:RSS != JVM committed
|
|
内存占用分解
Heap/Metaspace
|
|
实际占用
Heap = SC + EC + OC = 16384 + 262144 + 245760 = 524288
Metaspace = 155596
栈空间
默认 ThreadStackSize
123$java -XX:+PrintFlagsFinal -version | grep ThreadStackSizeintx ThreadStackSize = 1024 {pd product}intx VMThreadStackSize = 1024 {pd product}
线程数量
12$jstack 25921 | grep -oP '(?<=java.lang.Thread.State: )\w+' | wc -l423
实际占用
ThreadStackSize 线程数量 = 1024 423 = 433152
注意:这个实际上是Reserved
内存,NMT报告为了Committed
,JDK-8191369其他
- 直接申请的堆外内存,如DirectBuffer
- Codecache
Native Memory Tracking
JDK1.8自带的内存统计工具,通过-XX:NativeMemoryTracking=summary
启用,启用会带来5~10%的性能开销
|
|