01 机器内存告警,查看jvm内存及gc情况
老年代占比接近90%
S0 S1 E O M CCS YGC YGCT FGC FGCT GCT
45.24 0.00 70.10 89.96 90.22 84.81 2482 107.995 3 2.037 110.032
45.24 0.00 70.45 89.96 90.22 84.81 2482 107.995 3 2.037 110.032
45.24 0.00 70.73 89.96 90.22 84.81 2482 107.995 3 2.037 110.032
45.24 0.00 71.05 89.96 90.22 84.81 2482 107.995 3 2.037 110.032
45.24 0.00 71.23 89.96 90.22 84.81 2482 107.995 3 2.037 110.032`
02 手动触发一次fullGC后继续统计
发现老年代占比下降到了5%左右
疑惑多次yanggc回收不掉的对象漏到老年代之后,为啥能被一次fullgc回收?判断一个对象能否被回收的算法应该都是根搜索法呀,没道理漏到老年代之后引用都失效。推测跟gc收集器特点有关——yanggc使用的是Parallel Scavenge,该收集器关注的是系统的吞吐量;也就是说其实yanggc判断对象也是可以回收的,但是为了满足系统预设的吞吐量,没有回收这些对象。
S0 S1 E O M CCS YGC YGCT FGC FGCT GCT
45.24 0.00 71.05 89.96 90.22 84.81 2482 107.995 3 2.037 110.032
45.24 0.00 71.23 89.96 90.22 84.81 2482 107.995 3 2.037 110.032
0.00 23.12 0.00 89.98 90.22 84.81 2483 108.031 4 2.037 110.068
0.00 0.00 0.41 5.75 90.00 84.44 2483 108.031 4 2.477 110.507
0.00 0.00 0.73 5.75 90.00 84.44 2483 108.031 4 2.477 110.507
03 对比fullGC前后heap的使用情况
fullGC前
using thread-local object allocation.
Parallel GC with 8 thread(s)
Heap Configuration:
MinHeapFreeRatio = 0
MaxHeapFreeRatio = 100
MaxHeapSize = 4294967296 (4096.0MB)
NewSize = 1431306240 (1365.0MB)
MaxNewSize = 1431306240 (1365.0MB)
OldSize = 2863661056 (2731.0MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 536870912 (512.0MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 2147483648 (2048.0MB)
G1HeapRegionSize = 0 (0.0MB)
Heap Usage:
PS Young Generation
Eden Space:
capacity = 1371013120 (1307.5MB)
used = 1357456104 (1294.5710220336914MB)
free = 13557016 (12.928977966308594MB)
99.01116803316951% used
From Space:
capacity = 30932992 (29.5MB)
used = 12337216 (11.76568603515625MB)
free = 18595776 (17.73431396484375MB)
39.88368147510593% used
To Space:
capacity = 29360128 (28.0MB)
used = 0 (0.0MB)
free = 29360128 (28.0MB)
0.0% used
PS Old Generation
capacity = 2863661056 (2731.0MB)
used = 2856853056 (2724.5073852539062MB)
free = 6808000 (6.49261474609375MB)
99.76226236740777% used
49437 interned Strings occupying 5198632 bytes.
fullGC后
Heap Configuration:
MinHeapFreeRatio = 0
MaxHeapFreeRatio = 100
MaxHeapSize = 4294967296 (4096.0MB)
NewSize = 1431306240 (1365.0MB)
MaxNewSize = 1431306240 (1365.0MB)
OldSize = 2863661056 (2731.0MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 536870912 (512.0MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 2147483648 (2048.0MB)
G1HeapRegionSize = 0 (0.0MB)
Heap Usage:
PS Young Generation
Eden Space:
capacity = 1380450304 (1316.5MB)
used = 692010592 (659.9527282714844MB)
free = 688439712 (656.5472717285156MB)
50.129337506379365% used
From Space:
capacity = 25165824 (24.0MB)
used = 0 (0.0MB)
free = 25165824 (24.0MB)
0.0% used
To Space:
capacity = 24117248 (23.0MB)
used = 0 (0.0MB)
free = 24117248 (23.0MB)
0.0% used
PS Old Generation
capacity = 2863661056 (2731.0MB)
used = 208333416 (198.6822280883789MB)
free = 2655327640 (2532.317771911621MB)
7.275072430918305% used
48278 interned Strings occupying 5113608 bytes.
发现年轻代、老年代均有大量对象被回收,但是年轻代还有将近700M、来年代还有将近200M。
04 杀了个dump看看
发现大量占用内存的对象跟公司rpc框架有关,排查代码,发现rpc失败后,存在内存泄漏的风险。后面有时间写文章分享