【发布时间】:2020-03-09 15:41:13
【问题描述】:
有没有办法释放@AfterChunks 中的JVM 内存?因为我们在处理了几条记录后遇到了 outOfMemory 错误。
春季批处理作业完成后有没有办法释放内存?
Public class ABC implements ChunkListener{
private static final Logger log = oggerFactory.getLogger(ABC .class);
private MessageFormat fmt = new MessageFormat("{0} items processed");
private int loggingInterval = 100;
@Override
public void beforeChunk(ChunkContext context) {
// Nothing to do here
}
@Override
public void afterChunk(ChunkContext context) {
int count = context.getStepContext().getStepExecution().getReadCount();
// If the number of records processed so far is a multiple of the logging interval then output a log message.
if (count > 0 && count % loggingInterval == 0) {
log.info( fmt.format(new Object[] {new Integer(count) })) ;
}
//String name = context.getStepContext().getStepName();
//context.getStepContext().registerDestructionCallback(name, callback);
}
如何拨打registerDestructionCallback清理?什么是名称和回调?有参考吗?
【问题讨论】:
标签: spring-boot out-of-memory spring-batch