[QUESTION] fastjson2 DynamicClassLoader 占用非堆内存过大
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
openjdk version "1.8.0_342"
k8s容器,5.10.134-13.al8.x86_64 #1 SMP Mon Jan 9 10:50:49 CST 2023 x86_64 GNU/Linux
fastjson版本:2.0.52
监控系统显示非堆内存占比高达85%,
进入k8s容器终端,使用以下命令
jcmd 1 VM.classloader_stats | grep com.alibaba.fastjson
结果如下:
0x00000007c11c2e88 0x00000007c0506c28 0x00007f3173740050 21 319488 294536 com.alibaba.fastjson.util.ASMClassLoader
0x00000007c11c2e88 0x00000007c0506c28 0x00007f2fe00ea400 7 155648 94544 com.alibaba.fastjson.util.ASMClassLoader
0x00000007c196daa8 0x00000007c0060218 0x00007f2e88045dc0 1 10240 6224 com.alibaba.arthas.deps.com.alibaba.fastjson.util.ASMClassLoader
0x00000007c196daa8 0x00000007c0060218 0x00007f2f4800f8b0 18 319488 234784 com.alibaba.arthas.deps.com.alibaba.fastjson.util.ASMClassLoader
0x00000007c1188480 0x00000007c0506c28 0x00007f2f600b4010 16452 432476160 432152624 com.alibaba.fastjson2.util.DynamicClassLoader
监控系统显示,每天晚上1:30左右,metaspace有跳跃式增长
经排查发现晚上1点30左右有定时任务,执行过程中有多处打印日志使用了JSON.toJSONString();
deepseek分析jcmd 1 VM.classloader_stats | grep com.alibaba.fastjson命令结果如下:
昨天升级了fastjson2版本到2.0.52,今天早上观察情况并未改善。
Contributor guide
Research direction
Start with fastjson2's DynamicClassLoader and the scheduled-task paths that call JSON.toJSONString(); compare class-loader and metaspace usage before and after the nightly 1:30 run. Use jcmd 1 VM.classloader_stats and the reported fastjson2 version and JDK details to investigate whether repeated serialization is associated with class accumulation. Done means identifying the cause of the growth and documenting a verified mitigation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100