-->
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.  [ 3 posts ] 
Author Message
 Post subject: Inefficient HashMap initialization
PostPosted: Fri May 26, 2006 8:44 am 
Newbie

Joined: Fri May 26, 2006 8:37 am
Posts: 2
Location: Sulake Corporation
Hello,

we have an entity which has a <map>-type of collection attached to it, that uses <many-to-many> mapping. The map has cache setting of <cache usage="nonstrict-read-write"/>

The problem is that the map is often quite large, 500-1000 elements in it. But when Hibernate3 instantiates it from cache (PersistentMap.initializeFromCache()), it will create a HashMap with default parameters and then .put() each item from the serialized cache data to the map.

HashMap default size is 16 and it resizes it to double always when it has 75%*capacity elements in it. So, initializing a HashMap with 1000 entries will cause 7 resizes (which are expensive): 16->32->64->128->256->512->1024->2048. This consumes a lot of memory and cpu...

Is there are way to go around this or should I hack the source?

Best regards,
Aapo


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 26, 2006 10:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Enter an enhancement request into JIRA. That is a totally reasonable feature.


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 27, 2006 5:17 pm 
Newbie

Joined: Fri May 26, 2006 8:37 am
Posts: 2
Location: Sulake Corporation
Thanks, I have entered it: http://opensource.atlassian.com/project ... e/HHH-1789


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.