-->
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.  [ 4 posts ] 
Author Message
 Post subject: memory problems with many inserts despite flush() clear()
PostPosted: Thu Jul 21, 2005 3:16 pm 
Newbie

Joined: Fri Nov 12, 2004 2:04 pm
Posts: 5
Greetings,

I am using Hibernate 2 to insert a large number of Objects in to a database. I know the standard answer is that ORM tools are less suitable for this type of task but that's what I'm trying to do anyway. 8)

I read this in the FAQ:

http://blog.hibernate.org/cgi-bin/blosx ... 8/26#batch

Here Gavin suggests changing the batch size and calling flush() and clear() on the Session regularly.

In my case I have done both.

However, running a profiler reveals that in the SessionImpl class there is a field named "executions" (ArrayList) which is holding references to my Objects. I looked at the hibernate source and it seems that the executions is only cleared after a transaction is complete.

The result is the executions ArrayList grows holding Objects that should have already been flushed until the application goes out of memory.

Looking over the forums I have found similar messages such as:

http://forum.hibernate.org/viewtopic.ph ... executions

http://forum.hibernate.org/viewtopic.ph ... executions

http://forum.hibernate.org/viewtopic.ph ... executions

One poster suggested that 2.1.7 resolved this but I tried it with 2.1.7 (was using 2.1.3) and the problem still exists.

I also understand that if you commit the transaction periodically it will clear the executions ArrayList however that does not fit my particular use case.

Does anyone know if this is a bug and if there is a workaround?

Thank you for your time.

Derek


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 21, 2005 5:40 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Hibernate *has* to hold onto certain things until the end of the txn (it is cache-related stuff).

You can disable the second level cache, and this problem will go away.

Or you can use StatelessSession in 3.1.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 22, 2005 6:28 pm 
Newbie

Joined: Fri Nov 12, 2004 2:04 pm
Posts: 5
Indeed it did. Thanks for the reply.

Derek


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 24, 2005 7:53 am 
Regular
Regular

Joined: Thu Nov 20, 2003 10:04 pm
Posts: 64
Location: Melbourne, Australia
gavin wrote:
Hibernate *has* to hold onto certain things until the end of the txn (it is cache-related stuff).

You can disable the second level cache, and this problem will go away.

Or you can use StatelessSession in 3.1.


Is there any better solutions to this?

The second level cache provides some nice speed improvements so I'd rather not disable it if I can get away with it. Also 3.1 is a bit too bleeding edge for us at the moment (still on 2.x).


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

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.