I have machine with 16G RAM. I run a java application with arguments -Xms9G -Xmx9G
.
When I run top
command I see that my java process is taking 13.8g VIRT, but only 4.6g of RES.
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5019 root 20 0 13.8g 4.7g 18m S 0.7 30.7 3:28.39 java
On running pmap
command, I see that only ~3.9g of heap is present as RES, rest 5.7g is in virtual.
Address Kbytes RSS Dirty Mode Mapping
0000000580000000 9452384 4074228 4074228 rw--- [ anon ]
Upon monitoring HPCUR with jvmtop
, I observe that the GC is triggered when the HPCUR reaches about 3g.
PID MAIN-CLASS HPCUR HPMAX NHCUR NHMAX CPU GC VM USERNAME #T DL
5019 .1-SNAPSHOT.jar 408m 9216m 192m n/a 0.25% 0.00% O8U20 webapp 823
I observe that the RES for the process increases gradually, heap memory in RES (by pmap) also increases gradually too. As a result GC threshold increases.
I have several questions about this behavior.
- Is only the heap that is present in RES used, and not the VIRT?
- If I have allotted 9G min heap (
-Xms
), then initially why only 3.9g RES is allotted. Isn't this same as keeping -Xms low? What is the point of keeping -Xms=-Xmx then? - On what basis is it decided that how much heap should be in RES? Read somewhere that its managed by OS, but any rough logic?
- Any way to make sure, that the allotted heap is actually used?