log4jdbc icon indicating copy to clipboard operation
log4jdbc copied to clipboard

OOM when using batchUpdate

Open GoogleCodeExporter opened this issue 9 years ago • 3 comments

What steps will reproduce the problem?
1. using batchUpdate with thousands of insert records
2.
3.

What is the expected output? What do you see instead?
should not give OOM

What version of the product are you using? On what operating system?
1.2

Please provide any additional information below.

Caused by: java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Arrays.java:2882)
        at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
        at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:390)
        at java.lang.StringBuffer.append(StringBuffer.java:224)
        at net.sf.log4jdbc.Slf4jSpyLogDelegator.buildSqlTimingDump(Slf4jSpyLogDelegator.java:415)
        at net.sf.log4jdbc.Slf4jSpyLogDelegator.sqlTimingOccured(Slf4jSpyLogDelegator.java:370)
        at net.sf.log4jdbc.StatementSpy._reportSqlTiming(StatementSpy.java:333)
        at net.sf.log4jdbc.StatementSpy.reportSqlTiming(StatementSpy.java:310)
        at net.sf.log4jdbc.StatementSpy.executeBatch(StatementSpy.java:527)
        at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
        at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
        at org.springframework.jdbc.core.JdbcTemplate$4.doInPreparedStatement(JdbcTemplate.java:881)
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:591)
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:619)
        at org.springframework.jdbc.core.JdbcTemplate.batchUpdate(JdbcTemplate.java:866)
        at org.springframework.jdbc.core.simple.SimpleJdbcTemplate.doExecuteBatchUpdate(SimpleJdbcTemplate.java:266)
        at org.springframework.jdbc.core.simple.SimpleJdbcTemplate.batchUpdate(SimpleJdbcTemplate.java:243)

Original issue reported on code.google.com by [email protected] on 19 Jun 2013 at 6:56

GoogleCodeExporter avatar Mar 30 '15 12:03 GoogleCodeExporter

when use MyBatis,and  execute batchSave also OOM

example:

    <insert id="batchSave">
        insert into table_name(id,column_a,column_b,date_time)
        <foreach collection="list" item="item" index="index" separator="UNION ALL">
            select sys_guid(),
            #{item.columnA,jdbcType=VARCHAR},
            #{item.columnB,jdbcType=VARCHAR},
            sysdate
            from dual
        </foreach>
    </insert>


Original comment by [email protected] on 17 Apr 2014 at 2:25

  • Added labels: ****
  • Removed labels: ****

GoogleCodeExporter avatar Mar 30 '15 12:03 GoogleCodeExporter

What is your batch size?

Original comment by [email protected] on 17 Apr 2014 at 10:39

  • Added labels: ****
  • Removed labels: ****

GoogleCodeExporter avatar Mar 30 '15 12:03 GoogleCodeExporter

Is there a way to resolve this

Original comment by [email protected] on 25 Nov 2014 at 7:30

  • Added labels: ****
  • Removed labels: ****

GoogleCodeExporter avatar Mar 30 '15 12:03 GoogleCodeExporter