-->
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: Session Memory Management Revisited.
PostPosted: Tue Mar 02, 2010 7:23 pm 
Newbie

Joined: Fri Nov 25, 2005 4:44 pm
Posts: 12
Hi folks this is follow up from a previous question (which I was able to answer). This is one is slightly different (in this case we are in fact creating new entities) but essentially the same problem, the JPA EntityManager (session) is holding on to entities longer then it needs to.

The psuedo code below more or less does this:
(fetch a bunch of entites give an id list, clone them, perist the cloned records back into the dabase).

Code:
while(!done) 
{
  List<Entity> entities = findByIds(bigIdList);
  for (Entity e : entities)
  {
         tmp = new Entity(e); 
         tmp.setId(null);
         entityManager.persist(tmp);
   }
   entityManager.flush(); // send the 'transactional info off to the database
   entityManager.clear(); // flush all entities form the session.
}
transaction.commit();


From what I can tell based on visualVM, my entity cont contnue to climb, regardless of the flush/clear operations.

Any thoughts as to what/why the session is still holding the references?

note:
Looking closer at Memory heap, shows, references are being held from something in hibernate/jpa:
EntityIdentityInsertAction <- ActionQueue <-SessionImpl

so indeed the session is not flushing the insert sql over to the database....

Thanx
Dan


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.