[BUG] com.alibaba.fastjson2.JSONFactory.CACHE_ITEMS内存泄露导致OOM
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
*简要描述您碰到的问题。*
com.alibaba.fastjson2.JSONFactory#CACHE_THRESHOLD 8M长度太大,16个缓存对象长时间运行后最大占用384M内存,且不能回收,小内存场景存在OOM,需要提供一个开关可以关闭缓存能力或者配置缓存大小
### 环境信息
*请填写以下信息:*
- OS信息: [e.g.:CentOS 8.4.2105 4Core 3.10GHz 16 GB]
- JDK信息: [e.g.:Openjdk 1.8.0_312]
- 版本信息:[e.g.:Fastjson2 2.x.x]
### 重现步骤
*如何操作可以重现该问题:*
1. 使用 `xxx.xxx` 方法
2. 输入 `...` 数据
3. 出现 `...` 错误
```java
//可在此输入示例代码
```
### 期待的正确结果
不能占用太多内存
#### 附加信息
Contributor guide
Research direction
Start at com.alibaba.fastjson2.JSONFactory, especially CACHE_THRESHOLD and CACHE_ITEMS, and inspect how the 16 cache objects are retained. Reproduce the long-running memory growth in the reported small-memory scenario, then verify that cache control or size configuration bounds retention and avoids OOM.
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