我的应用程序是用netty编写的,最近被oom killer杀死。我不确定是否存在内存泄漏。
我的Linux服务具有4 cpu和8G内存。我正在运行tomcat和netty程序。 netty APP有我的JVM标志:
VM Flags:
Non-default VM flags: -XX:CICompilerCount=3 -XX:GCLogFileSize=10485760 -XX:InitialHeapSize=3221225472 -XX:MaxHeapSize=3221225472 -XX:MaxNewSize=1073741824 -XX:MinHeapDeltaBytes=524288 -XX:NativeMemoryTracking=null -XX:NewSize=1073741824 -XX:NumberOfGCLogFiles=10 -XX:OldSize=2147483648 -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseGCLogFileRotation -XX:+UseParallelGC
如您所见,我使用NMT跟踪内部内存使用情况,并且每分钟记录摘要数据。
Sat Dec 22 17:48:01 CST 2018
11568:
Native Memory Tracking:
Total: reserved=4748707KB, committed=3474051KB
Java Heap (reserved=3145728KB, committed=3145728KB)
(mmap: reserved=3145728KB, committed=3145728KB)
Class (reserved=1076807KB, committed=31047KB)
(classes #3973)
(malloc=5703KB, #7662)
(mmap: reserved=1071104KB, committed=25344KB)
Thread (reserved=53715KB, committed=53715KB)
(thread #52)
(stack: reserved=53456KB, committed=53456KB)
(malloc=166KB, #266)
(arena=93KB, #104)
Code (reserved=253349KB, committed=24485KB)
(malloc=3749KB, #5611)
(mmap: reserved=249600KB, committed=20736KB)
GC (reserved=120705KB, committed=120705KB)
(malloc=5773KB, #165)
(mmap: reserved=114932KB, committed=114932KB)
Compiler (reserved=231KB, committed=231KB)
(malloc=132KB, #259)
(arena=99KB, #3)
Internal (reserved=72938KB, committed=72906KB)
(malloc=72906KB, #5771)
(mmap: reserved=32KB, committed=0KB)
Symbol (reserved=5690KB, committed=5690KB)
(malloc=4020KB, #30930)
(arena=1670KB, #1)
Memory Tracking (reserved=4962KB, committed=4962KB)
(malloc=4962KB, #232)
Pooled Free Chunks (reserved=14581KB, committed=14581KB)
(malloc=14581KB)
我在12月22日启动该应用程序,Internal memory
只有72906KB。但是,当我在12月24日获得最新数据时,Internal memory
的大小为2041923KB,几乎是12月22日数据的30倍。
Mon Dec 24 14:55:01 CST 2018
11568:
Native Memory Tracking:
Total: reserved=6707204KB, committed=5432760KB
Java Heap (reserved=3145728KB, committed=3145728KB)
(mmap: reserved=3145728KB, committed=3145728KB)
Class (reserved=1078933KB, committed=32149KB)
(classes #4035)
(malloc=5781KB, #9741)
(mmap: reserved=1073152KB, committed=26368KB)
Thread (reserved=54779KB, committed=54779KB)
(thread #53)
(stack: reserved=54484KB, committed=54484KB)
(malloc=169KB, #271)
(arena=126KB, #106)
Code (reserved=253940KB, committed=26312KB)
(malloc=4340KB, #6484)
(mmap: reserved=249600KB, committed=21972KB)
GC (reserved=120704KB, committed=120704KB)
(malloc=5772KB, #149)
(mmap: reserved=114932KB, committed=114932KB)
Compiler (reserved=277KB, committed=277KB)
(malloc=178KB, #281)
(arena=99KB, #3)
Internal (reserved=2041955KB, committed=2041923KB)
(malloc=2041923KB, #6058)
(mmap: reserved=32KB, committed=0KB)
Symbol (reserved=5771KB, committed=5771KB)
(malloc=4069KB, #31110)
(arena=1702KB, #1)
Memory Tracking (reserved=4962KB, committed=4962KB)
(malloc=4962KB, #222)
Pooled Free Chunks (reserved=156KB, committed=156KB)
(malloc=156KB)
因此,netty应用程序占用的内存超过5G(堆3G +内部2G)。服务器的内存即将用完
top - 15:42:37 up 384 days, 22:55, 1 user, load average: 0.84, 0.90, 0.94
Tasks: 108 total, 1 running, 107 sleeping, 0 stopped, 0 zombie
%Cpu(s): 15.7 us, 4.9 sy, 0.0 ni, 76.7 id, 0.0 wa, 0.0 hi, 2.7 si,0.0 st
KiB Mem : 8010424 total, 123472 free, 7481940 used, 405012 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 155052 avail Mem