Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to calculate the HashMap size interms of memory usage  RSS feed

 
Ramana Yeruva
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the source code for HashMap - figure out what each entry takes - multiply
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • 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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!