我需要有关Java内存存储的一些帮助:)
我正在使用OpenJDK 8
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
我使用top命令跟踪进程大小
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ SWAP COMMAND
22608 jboss-as 20 0 6758m 3.9g 9.9m S 51.5 80.7 228:32.00 5676 java
我使用NMT跟踪Java Non-HEAP大小
Native Memory Tracking:
Total: reserved=4665488KB, committed=3556452KB
Java Heap (reserved=2097152KB, committed=2064384KB) <----- Xmx2G
(mmap: reserved=2097152KB, committed=2064384KB)
Class (reserved=1340504KB, committed=335928KB)
(classes #46520)
(malloc=13400KB #115651)
(mmap: reserved=1327104KB, committed=322528KB)
Thread (reserved=779761KB, committed=779761KB)
(thread #756)
(stack: reserved=776140KB, committed=776140KB)
(malloc=2576KB #3779)
(arena=1045KB #1508)
Code (reserved=280354KB, committed=208726KB)
(malloc=30754KB #33717)
(mmap: reserved=249600KB, committed=177972KB)
GC (reserved=80261KB, committed=80197KB)
(malloc=3637KB #5609)
(mmap: reserved=76624KB, committed=76560KB)
Compiler (reserved=2088KB, committed=2088KB)
(malloc=1957KB #5009)
(arena=131KB #5)
Internal (reserved=30202KB, committed=30202KB)
(malloc=30170KB #70175)
(mmap: reserved=32KB, committed=32KB)
Symbol (reserved=43736KB, committed=43736KB)
(malloc=39605KB #465754)
(arena=4131KB #1)
Native Memory Tracking (reserved=11068KB, committed=11068KB)
(malloc=93KB #1044)
(tracking overhead=10975KB)
我使用GC日志“跟踪” Java堆大小
[Full GC (Ergonomics) [PSYoungGen: 19958K->0K(567808K)] [ParOldGen: 1378120K->834059K(1398272K)] 1398079K->834059K(1966080K), [Metaspace: 278065K->278025K(1327104K)], 1,2636863 secs] [Times: user=2,16 sys=0,00, real=1,26 secs]
理论上, Java进程大小=已使用的堆内存 +已使用的非堆内存
所以,我不了解我的进程java(3.9G)大于最大堆(-Xmx2G)+未提交堆(1.4G),在其他世界中,为什么我的进程java大于NTM提交的总内存?
从理论上讲,已用内存<已提交内存<已分配内存
谢谢,理论上的回答是:Java using much more memory than heap size
[更新1]
我用 mpap 命令进行了内存捕获:
总 RSS 与流程大小匹配
Address Kbytes RSS Dirty Mode Mapping
0000000000400000 4 0 0 r-x-- java (deleted)
0000000000600000 4 4 4 rw--- java (deleted)
... ... ... ...
total kB 6957732 4070428 4060060
但是我不明白为什么大多数Java库的rss大小为零。可能有人可以解释吗?
00007fc86aa78000 16 0 0 r--s- commons-io-2.5.jar
大多数内存消耗非离子区域。如何从堆和非堆中找出内存在哪里消费?
grep "anon" pmap-result.csv | sort -k6 | awk '{ sum+=$3} END {print sum}'
4059388
使用jmx-console,我只发现内存使用直接缓冲池:11012474字节(10.5 mb) here