• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to calculate the HashMap size interms of memory usage

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at the source code for HashMap - figure out what each entry takes - multiply
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ramana Yeruva:



I guess the question was all in the title. However, posting big rows of gremlins won't endear you to JavaRanch community. As you're new to us, perhaps you would read HowToAskQuestionsOnJavaRanch.

Regarding your question, there is deliberately no way in Pure Java to ask how much memory will be used by an object or primitive. Java programming is supposed to be at least one step above such considerations, and you should not write a Java program that depends on knowing about low-level memory issues.

The amount of memory used by an object or primitive varies between JVMs. You can probably find out how to estimate it for a particular JVM.
[ December 05, 2007: Message edited by: Peter Chase ]
reply
    Bookmark Topic Watch Topic
  • New Topic