manash
manash

Reputation: 7106

Total memory used by Java process and heap size

I wrote an application using Spring Batch. I can see with VisualVM that the heap size is about 22 MB. But, when I use Process Explorer (on Windows) to see how much memory is used by it, the difference is big (Private bytes - 71560K and Working Set - 80388K). How to explain this? What are the other things that use this memory?

Thanks

Upvotes: 13

Views: 2582

Answers (2)

Peter Lawrey
Peter Lawrey

Reputation: 533432

There is shared libraries, Thread's stack, perm gen, direct memory, memory mapped files.

However, the JVM allocates the maximum heap size on startup. The amount used doesn't matter so much.

Upvotes: 5

aishwarya
aishwarya

Reputation: 1976

don't forget the native space (stack)! The heap only represents objects, threads/ primitives take up additional memory. Also AFAIK, once a process takes up memory, even though the contents may be garbage collected, it is at times not released back to the OS. Plus, I am not sure of VisualVM, but eclipse MAT only shows heap that is "current" (will not be garbage collected if GC was run at that point in time). You may also want to look at jstat.

Upvotes: 2

Related Questions