我正在使用 ThreadPoolTaskExecutor
异步执行少量操作。我得到的内存泄漏如下。 ThreadPoolTaskExecutor
配置
@Bean(name = "specificTaskExecutor")
public Executor asyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(20);
executor.setMaxPoolSize(100);
executor.setThreadNamePrefix("Seperate");
TaskDecorator taskDecorator = (Runnable runnable) -> {
Map<String, String> contextMap = MDC.getCopyOfContextMap();
return () -> {
try {
MDC.setContextMap(contextMap);
runnable.run();
} finally {
MDC.clear();
}
};
};
executor.setTaskDecorator(taskDecorator);
executor.initialize();
return executor;
}
异步使用:
@Async("specificTaskExecutor")
Public void asyncMethod(){
// some functionality
}
内存泄漏:
请让我知道我在这里丢失了什么导致内存泄漏。
暂无答案!
目前还没有任何答案,快来回答吧!