spring jdbctemplate.batchupdate(sql,List <object []>)内存不足

时间:2018-02-06 13:55:17

标签: spring spring-batch spring-jdbc

我的应用程序每5分钟运行一次,以便将相同的数据(可能会改变一点点)加载到数据库中。

当使用Spring批处理插入行时,内存消耗仍然很好,内存被垃圾收集,因此下次运行时看不到内存峰值。

然而,在使用Spring的jdbctemplate.batchupdate()手动执行batchupdate时,我发现内存需要很长时间才能获得GC。

有关正在发生的事情的任何提示?

1 个答案:

答案 0 :(得分:0)

使用JdbcTemplate batchUpdate方法(batchUpdate(String sql, final Collection<T> batchArgs, final int batchSize, final ParameterizedPreparedStatementSetter<T> pss))时遇到了同样的问题。

但我确实通过精确设置堆大小(基于对象和批量大小)来管理解析它,并提供clearParameters(ParameterDisposer)方法实现来释放分配给参数的资源。

我的自定义ParameterizedPreparedStatementSetter实现了ParameterizedPreparedStatementSetter和ParameterDisposer。

相关问题