堆外内存的使用与释放问题
- Dominant language
- Java
- Stars
- 37.5k
- Forks
- 7.6k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 4
Description
- [ ] 我已经在 [issues](https://github.com/alibaba/arthas/issues) 里搜索,没有重复的issue。
### 环境信息
* `arthas-boot.jar` 3.5.5
* Arthas 版本: 3.5.5
* 操作系统版本: win11
* 目标进程的JVM版本: 1.8
* 执行`arthas-boot`的版本: 3.5.5
### 重现问题的步骤
1. xxx
```java
public static void main(String[] args) throws InterruptedException {
// 300M
byte[] bytes = new byte[1024 * 1024 * 300];
TimeUnit.MINUTES.sleep(10);
}
```
2. 使用arthas-boot.jar attach应用,发现进程的内存消耗增加了将近100M

3. 使用windows的资源管理器查看内存使用
arthas启动之前

arthas启动之后

4. 使用stop停止arthas,内存没有释放

资源管理器:

### 期望的结果
stop之后arthas占用的堆外内存应该释放
### 实际运行的结果
实际并没有释放内存,使用mat分析了堆快照,有100M左右的堆外内存是arthas占用的,
mat分析发现DircetByteBuffer的cleaner对象为null
Contributor guide
Research direction
Start by reproducing the Windows 11/JVM 8 case with arthas-boot.jar 3.5.5 and compare memory before attach and after stop. Use the provided sample program and MAT's DirectByteBuffer and cleaner observations to trace the retained off-heap allocation. Done means Arthas's off-heap memory is released after stop, with a regression test or documented verification of the result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100