Search code examples
javamemoryjvmsizeheap-memory

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


Solution

  • 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.