http://webmoli.com/2009/02/01/jdbc-performance-tuning-with-optimal-fetch-size/
我的问题是如何释放这段内存?运行GC无效,我猜测这是因为连接池中的连接仍然有效。代码:
public List<Msisdn> getNewMsisdnsForBulkSmsId(String bulkSmsId,String scheduleId,final int msisdnCount) throws SQLException {
JdbcTemplate jdbcTemplate = getJdbcTemplate();
jdbcTemplate.setFetchSize(500);
jdbcTemplate.setMaxRows(msisdnCount);
jdbcTemplate.query("select BULKSMS_ID, ? as , STATUSSELECTDATE, DELIVERYTIME, ID, MESSAGE from ada_msisdn partition (ID_"+bulkSmsId+") where bulksms_id = ? and status = 0 and ERRORCODE = 0 and SCHEDULEID is null for update skip locked", new Object[]{scheduleId,bulkSmsId}, MsisdnRowMapper.INSTANCE);
//Also i tried to close connection and run gc, this does not free the memory too.
//jdbcTemplate.getDataSource().getConnection().close();
//System.gc();
return null;
}
当我将获取大小设置为10时,堆大小为12 MB。如果将获取大小设置为500,则堆大小为206 MB。
谢谢。