alibaba / alibaba/arthas

堆外内存的使用与释放问题

Open
#2,114 1 comment 0 reactions 0 assignees View on GitHub
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
![image](https://user-images.githubusercontent.com/44093317/155670431-ba9b776e-aa52-4985-87ff-592630e8fc0a.png)

3. 使用windows的资源管理器查看内存使用
arthas启动之前
![image](https://user-images.githubusercontent.com/44093317/155670772-0a16c9f4-2a54-4e7b-93c5-4ca4b5db8c34.png)

arthas启动之后
![image](https://user-images.githubusercontent.com/44093317/155670838-2454e1d8-8a3f-423d-9f5b-95015cd0d0df.png)
4. 使用stop停止arthas,内存没有释放
![image](https://user-images.githubusercontent.com/44093317/155670897-f6cea9bd-b2e8-46d8-8f4b-3d1d204b0c88.png)

资源管理器:
![image](https://user-images.githubusercontent.com/44093317/155670945-1d0e616d-ca10-4560-aa1d-681fde54137e.png)

### 期望的结果

stop之后arthas占用的堆外内存应该释放

### 实际运行的结果

实际并没有释放内存,使用mat分析了堆快照,有100M左右的堆外内存是arthas占用的,
mat分析发现DircetByteBuffer的cleaner对象为null

Contributor guide

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.