性能问答>jvm堆外内存分析>
4回复
2年前

jvm堆外内存分析



问题描述:
某一个系统生产环境java进程占用6GB内存,但是堆的最大内存2GB,导致操作系统发现内存太大,直接被操作系统kill进程,由于项目里使用了rocketmq,使用了netty,通过硬编码方式查到netty 堆外noclear的内存在400Mb左右,2天前刚开始使用mq之后堆外是100MB左右,目前还不知道是哪块的问题,社区大神帮忙分析分析,谢谢

以下是刚开始执行的jcmd pid VM.native_memory diff命令:

38539:

Native Memory Tracking:

Total: reserved=4496412KB, committed=3326408KB
-                 Java Heap (reserved=2097152KB, committed=2097152KB)
                            (mmap: reserved=2097152KB, committed=2097152KB)

-                     Class (reserved=1193115KB, committed=160195KB)
                            (classes #24574)
                            (malloc=13467KB #59015)
                            (mmap: reserved=1179648KB, committed=146728KB)

-                    Thread (reserved=260787KB, committed=260787KB)
                            (thread #490)
                            (stack: reserved=258416KB, committed=258416KB)
                            (malloc=1605KB #2454)
                            (arena=766KB #976)

-                      Code (reserved=273322KB, committed=136238KB)
                            (malloc=23722KB #31388)
                            (mmap: reserved=249600KB, committed=112516KB)

-                        GC (reserved=85878KB, committed=85878KB)
                            (malloc=9254KB #887)
                            (mmap: reserved=76624KB, committed=76624KB)

-                  Compiler (reserved=1232KB, committed=1232KB)
                            (malloc=1102KB #3472)
                            (arena=131KB #6)

-                  Internal (reserved=546814KB, committed=546814KB)
                            (malloc=546782KB #36014)
                            (mmap: reserved=32KB, committed=32KB)

-                    Symbol (reserved=30738KB, committed=30738KB)
                            (malloc=26734KB #272996)
                            (arena=4004KB #1)

-    Native Memory Tracking (reserved=7204KB, committed=7204KB)
                            (malloc=689KB #9627)
                            (tracking overhead=6515KB)

-               Arena Chunk (reserved=170KB, committed=170KB)
                            (malloc=170KB)

2天后的差异值:

38539:

Native Memory Tracking:

Total: reserved=4699957KB +203732KB, committed=3539505KB +213284KB

-                 Java Heap (reserved=2097152KB, committed=2097152KB)
                            (mmap: reserved=2097152KB, committed=2097152KB)

-                     Class (reserved=1195446KB +2331KB, committed=162782KB +2587KB)
                            (classes #24734 +160)
                            (malloc=13750KB +283KB #58165 -844)
                            (mmap: reserved=1181696KB +2048KB, committed=149032KB +2304KB)

-                    Thread (reserved=302944KB +42125KB, committed=302944KB +42125KB)
                            (thread #571 +81)
                            (stack: reserved=300212KB +41796KB, committed=300212KB +41796KB)
                            (malloc=1872KB +266KB #2859 +405)
                            (arena=861KB +63 #1138 +162)

-                      Code (reserved=269464KB -3865KB, committed=141676KB +5431KB)
                            (malloc=19864KB -3865KB #22239 -9147)
                            (mmap: reserved=249600KB, committed=121812KB +9296KB)

-                        GC (reserved=85878KB +1KB, committed=85878KB +1KB)
                            (malloc=9254KB +1KB #903 +16)
                            (mmap: reserved=76624KB, committed=76624KB)

-                  Compiler (reserved=1438KB +206KB, committed=1438KB +206KB)
                            (malloc=1308KB +206KB #2563 -909)
                            (arena=131KB #6)

-                  Internal (reserved=709505KB +162691KB, committed=709505KB +162691KB)
                            (malloc=709473KB +162691KB #38434 +2420)
                            (mmap: reserved=32KB, committed=32KB)

-                    Symbol (reserved=30788KB +50KB, committed=30788KB +50KB)
                            (malloc=26784KB +50KB #273541 +545)
                            (arena=4004KB #1)

-    Native Memory Tracking (reserved=7167KB +125KB, committed=7167KB +125KB)
                            (malloc=753KB +197KB #10520 +2700)
                            (tracking overhead=6414KB -73KB)

-               Arena Chunk (reserved=174KB +68KB, committed=174KB +68KB)
                            (malloc=174KB +68KB)

netty统计堆外内存日志:

Jan 10 10:21:32 pay1 push[38537]: 2020-01-10 10:21:32.086  WARN 38539 --- [pool-6-thread-1] c.d.p.p.PlatformModuleAutoConfiguration  : memoryInfo: max memory:2047mb | total memory:2047mb | free memory:1453mb
Jan 10 10:21:32 pay1 push[38537]: 2020-01-10 10:21:32.086  WARN 38539 --- [pool-6-thread-1] c.d.p.p.PlatformModuleAutoConfiguration  : memoryInfo: maxDirectMemory:1963mb 是否支持noclear:true noclear占用堆外内存:112mb clear占用堆外内存:{ name:direct; count:30; memoryUsed:0;}{ name:mapped; count:0; memoryUsed:0;}
-------------------------------------------------------
Jan 13 14:15:32 pay1 push[38537]: 2020-01-13 14:15:32.086  WARN 38539 --- [pool-6-thread-1] c.d.p.p.PlatformModuleAutoConfiguration  : memoryInfo: max memory:2047mb | total memory:2047mb | free memory:142mb
Jan 13 14:15:32 pay1 push[38537]: 2020-01-13 14:15:32.086  WARN 38539 --- [pool-6-thread-1] c.d.p.p.PlatformModuleAutoConfiguration  : memoryInfo: maxDirectMemory:1963mb 是否支持noclear:true noclear占用堆外内存:432mb clear占用堆外内存:{ name:direct; count:114; memoryUsed:0;}{ name:mapped; count:0; memoryUsed:0;}
4212 阅读
请先登录,查看4条精彩评论吧
快去登录吧,你将获得
  • 浏览更多精彩评论
  • 和开发者讨论交流,共同进步