Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 430
manash Avatar asked Oct 26 '11 12:10

manash


2 Answers

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.

like image 186
Peter Lawrey Avatar answered Nov 17 '22 22:11

Peter Lawrey


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.

like image 2
aishwarya Avatar answered Nov 17 '22 23:11

aishwarya