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: PersistentList internal list has thousands of null entries
PostPosted: Wed Jul 20, 2011 3:06 pm 
Newbie

Joined: Wed Jul 20, 2011 2:51 pm
Posts: 1
It seems as if the PersistentList class pads its list with null values up to the index value of the first item being added. In our application, that item could have an index of over 1 million which causes 999,999 null entries to be added to the list. Heap analysis shows this list to be in the 11mb range which is quite a difference than the expected 800 bytes (4 list items @ 200 bytes each). Couple that with the fact that when you try to leverage caching, two copies of the list are kept, we are seeing a 23-24m object that should only be around 30k if you include the parent.

This was initially identified on 3.2.2 but it looks like 3.6 has the same code. Hopefully I am missing something really simple or there is some other way to use second level caching in the context of list associations that is a bit less memory intensive.

Any advice much appreciated.

Regards,
Chris

Code:
public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
throws HibernateException, SQLException {
   Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ) ;
   int index = ( (Integer) persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() ) ).intValue();
      
   //pad with nulls from the current last element up to the new index
   for ( int i = list.size(); i<=index; i++) {
      list.add(i, null);
   }
      
   list.set(index, element);
   return element;
}


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.