1

Possible Duplicate:
How to monitor Java memory usage?

My Java Program loads hash map with large number of values from the database. Is there any way through which I may know that how much memory each of my hash map is using during the program is running.

I am aware that it may not be a constant value but any near approximation will also do. Or maybe how much memory each of the hash map consumes while it is loaded with data from Sql Server.

Thanks

Community
  • 1
  • 1
JavaBits
  • 2,005
  • 11
  • 36
  • 40

2 Answers2

2

If you want to estimate the size of specific data structures at runtime, Heinz Kabutz's newsletter describes how to do this using instrumentation: Instrumentation Memory Counter.

McDowell
  • 107,573
  • 31
  • 204
  • 267
0

If you want an estimate use a profiler like VisualVM or YourKit.

You could estimate how large an entry key/value is and multiply it by the number of entries.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130