JobTimeoutTask leak problems
- Dominant language
- Java
- Stars
- 37.6k
- Forks
- 7.6k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 4
Description
- [ ] 我已经在 [issues](https://github.com/alibaba/arthas/issues) 里搜索,没有重复的issue。
### 环境信息
* Arthas 版本: 3.5.3
* 操作系统版本: xxx
* 目标进程的JVM版本: xxx
### 问题描述
分析Java memory dump时发现有大量未释放的JobTimeoutTask实例:

可能是Job管理存在问题,` jobTimeoutTask.cancel()` 并没有从ExecutorService中取消job
```java
@Override
public Job createJob(InternalCommandManager commandManager, List tokens, Session session, JobListener jobHandler, Term term, ResultDistributor resultDistributor) {
final Job job = super.createJob(commandManager, tokens, session, jobHandler, term, resultDistributor);
/*
* 达到超时时间将会停止job
*/
JobTimeoutTask jobTimeoutTask = new JobTimeoutTask(job);
long jobTimeoutInSecond = getJobTimeoutInSecond();
Date timeoutDate = new Date(System.currentTimeMillis() + (jobTimeoutInSecond * 1000));
ArthasBootstrap.getInstance().getScheduledExecutorService().schedule(jobTimeoutTask, jobTimeoutInSecond, TimeUnit.SECONDS);
jobTimeoutTaskMap.put(job.id(), jobTimeoutTask);
job.setTimeoutDate(timeoutDate);
return job;
}
@Override
public boolean removeJob(int id) {
JobTimeoutTask jobTimeoutTask = jobTimeoutTaskMap.remove(id);
if (jobTimeoutTask != null) {
jobTimeoutTask.cancel();
}
return super.removeJob(id);
}
```
```java
private static class JobTimeoutTask implements Runnable {
private Job job;
...
public void cancel() {
job = null;
}
}
```
Contributor guide
Research direction
Start by tracing the createJob and removeJob entry points shown in the issue, then inspect JobTimeoutTask and the scheduled executor lifecycle. Reproduce the job-removal flow with a memory dump or existing job lifecycle checks. Done means removed jobs no longer retain JobTimeoutTask instances while timeout handling still works.
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
- Mostly clear
- Newbie friendliness
- 35/100