Reputation: 11
I am trying to understand some system memory concepts.
If I have a Java program and its Max heap size is 5657m
And its heap used size as below: (around between 954M ~ 2.3G)
As far as I understand, if its heap size once reached 2.3G, the memory allocation would be at this level even though it went down to 954M internally within the JVM.
From system TOP command, this process current has RES of 2.7G.
*PID USER PR NI VIRT **RES** SHR S %CPU **%MEM** TIME+ COMMAND*
*13523 cloud-u+ 20 0 13.8g **2.7g** 7000 S 5.6 **8.7***
So can I conclude that:
RES 2.7G = This Java process "Max of Heap size currently ever reached" + "non-Heap part" size?
Since Heap ever reached 2.3G, the RES would never less than 2.3G ?
Since the max heap is 5657m, the max of RES = 5657m + "non-Heap part" ?
Upvotes: 1
Views: 1308
Reputation: 308051
Your conclusions are roughly correct.
There is however one mistake in #2: The JVM can return memory back to the OS and thus the RES value can shrink. But by default the JVM is very reluctant to do that (to a point where it's rare to see it unless you explicitly configured).
This SO question has a detailed answer showing when exactly various versions of OpenJDK release memory back to the OS and how to tweak that.
Upvotes: 2