• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

HashMap capacity

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

{can anyone suggest me what values of Initial capacity and Load Factor of a hashmap, can Hold a maximum capacity,

My application is very bulk it when 170000 alarms are processed out of mem heap occurs, i was not allowed to increase my server heap size , since it reaches certain limit, only thing i can do is to increase the Hashmap capacity and check once more with my application...

I have tried using default (16,.75f)

have tried with (151,.6f)

also please tell me how to calculate the capacity that a hashmap can hold using these Initial capacity and load factor.
}
Thanks
regs
Mano
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I doubt it is related to the java.util.HashMap itself, more likely the data that is contained in the HashMap.
170k items is not an unreasonable size for a HashMap.
 
Marshal
Posts: 75719
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

There is nothing in the API about a maximum size, but I believe the actual size is always an exact power of 2. So your 170000 would actually be 524288. 2^18 is 262144, but 262144 * 0.6 < 170000, so it would double to 2^19 = 524288.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Given that it is backed by an Array with max size 2^31-1, or 2^30 when limited to powers of two. 2^19 still leaves plenty of room.
 
greenhorn
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Welcome to JavaRanch.

There is nothing in the API about a maximum size, but I believe the actual size is always an exact power of 2. So your 170000 would actually be 524288. 2^18 is 262144, but 262144 * 0.6 < 170000, so it would double to 2^19 = 524288.



So your 170000 would actually be 524288. 2^18 is 262144, but 262144 * 0.6 < 170000, so it would double to 2^19 = 524288.



why did you multiply by 0.6?

Given that it is backed by an Array with max size 2^31-1, or 2^30 when limited to powers of two. 2^19 still leaves plenty of room.



i am not getting the calculations.
 
Campbell Ritchie
Marshal
Posts: 75719
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pooja jain wrote: . . . why did you multiply by 0.6? . . .

Because in the earlier post it said

(151,.6f)

There is the 0.6.
 
I think he's gonna try to grab my monkey. Do we have a monkey outfit for this tiny ad?
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic