-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: calling executeUpdate() many times results in heap space err
PostPosted: Wed Jan 19, 2011 3:38 am 
Newbie

Joined: Wed Jan 19, 2011 3:19 am
Posts: 1
Hi,

I am getting a "java.lang.OutOfMemoryError: Java heap space" error when I call query.executeUpdate() many times within a transaction.
On my PC the following code (test code to prove the error) fails somewhere between 160000 and 170000. Is there an explanation for this? I know I can workaround this by dividing the work in multiple transactions. I am using Hibernate 3.2.6.GA.

Thanks.

Code:
             
                int count = 0;
      Query query = entityManager.createNativeQuery("insert into table_a select table_a_seq.nextval from dual");
      while (count < 200000) {
         query.executeUpdate();
         if (++count % 100 == 0) {
            session.clear();
         }
         if (count % 10000 == 0) {
            System.out.println("Count: " + count);
         }
      }


When running the code with JProbe (Java Profiler) the top runtime instances are:

java.util.HashMap$Entry -> count = 2.189.880
java.util.HashMap$Entry[] -> count = 24.606
java.util.HashMap -> count = 24.606

ps. I don't get the error if I change the insert into a select and call query.getResultList() in the while loop.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.