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

asked Jul 24, 2011 at 9:07
7
  • 1
    You could come to a rough esimate if you execute the program in an IDE and use its profiling features. I.e. you could use Eclipse + TPTP. Commented Jul 24, 2011 at 9:12
  • Yes I am using eclipse IDE. TPTP - can you clarify this a little more? Thanks Commented Jul 24, 2011 at 9:25
  • @Mitch - its definitely related but not a duplicate.:-) Commented Jul 24, 2011 at 9:28
  • JavaBits: well that's why the 'possible' is there I guess. Commented Jul 24, 2011 at 9:29
  • @JavaBits: ...and as far as I can see the answer in that question will work for you. Determine memory before and after you fill the hash map.... Commented Jul 24, 2011 at 9:30

2 Answers 2

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.

answered Jul 24, 2011 at 9:41
Sign up to request clarification or add additional context in comments.

Comments

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.

answered Jul 24, 2011 at 9:21

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.