Reputation: 12141
I'm trying to see how much memory I should give to a process. This is how I start the application.
'-server -Xmx10G -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:+PrintGCDetails -XX:+PrintGCTimeStamps'
So, I'm giving the application 10G. But I would like to know how much it really uses. Is that possible? I have this Garbage Collector log.
5997.472: [GC pause (young), 0.0195390 secs]
[Parallel Time: 9.6 ms, GC Workers: 8]
[GC Worker Start (ms): Min: 5997472.0, Avg: 5997476.1, Max: 5997480.9, Diff: 8.9]
[Ext Root Scanning (ms): Min: 0.0, Avg: 2.7, Max: 6.4, Diff: 6.4, Sum: 21.3]
[Update RS (ms): Min: 0.0, Avg: 0.1, Max: 0.2, Diff: 0.2, Sum: 0.5]
[Processed Buffers: Min: 0, Avg: 4.6, Max: 13, Diff: 13, Sum: 37]
[Scan RS (ms): Min: 0.3, Avg: 1.5, Max: 1.9, Diff: 1.6, Sum: 11.8]
[Code Root Scanning (ms): Min: 0.0, Avg: 0.2, Max: 0.3, Diff: 0.3, Sum: 1.6]
[Object Copy (ms): Min: 0.0, Avg: 0.3, Max: 0.8, Diff: 0.8, Sum: 2.5]
[Termination (ms): Min: 0.0, Avg: 0.4, Max: 0.5, Diff: 0.5, Sum: 3.5]
[GC Worker Other (ms): Min: 0.0, Avg: 0.1, Max: 0.2, Diff: 0.2, Sum: 0.7]
[GC Worker Total (ms): Min: 0.4, Avg: 5.2, Max: 9.4, Diff: 9.1, Sum: 41.7]
[GC Worker End (ms): Min: 5997481.3, Avg: 5997481.3, Max: 5997481.4, Diff: 0.2]
[Code Root Fixup: 0.1 ms]
[Code Root Migration: 0.6 ms]
[Clear CT: 1.1 ms]
[Other: 8.2 ms]
[Choose CSet: 0.0 ms]
[Ref Proc: 0.4 ms]
[Ref Enq: 0.0 ms]
[Free CSet: 7.7 ms]
[Eden: 5433.0M(5433.0M)->0.0B(5433.0M) Survivors: 1024.0K->1024.0K Heap: 9008.4M(10192.0M)->3575.4M(10192.0M)]
[Times: user=0.06 sys=0.01, real=0.02 secs]
6002.843: [GC pause (young), 0.0732310 secs]
[Parallel Time: 34.1 ms, GC Workers: 8]
[GC Worker Start (ms): Min: 6002843.5, Avg: 6002854.0, Max: 6002862.0, Diff: 18.5]
[Ext Root Scanning (ms): Min: 0.0, Avg: 5.3, Max: 23.1, Diff: 23.1, Sum: 42.6]
[Update RS (ms): Min: 0.0, Avg: 0.3, Max: 1.4, Diff: 1.4, Sum: 2.6]
[Processed Buffers: Min: 0, Avg: 6.2, Max: 27, Diff: 27, Sum: 50]
[Scan RS (ms): Min: 0.5, Avg: 2.5, Max: 5.1, Diff: 4.6, Sum: 20.0]
[Code Root Scanning (ms): Min: 0.0, Avg: 0.2, Max: 0.5, Diff: 0.5, Sum: 1.8]
[Object Copy (ms): Min: 0.0, Avg: 1.6, Max: 10.2, Diff: 10.2, Sum: 12.4]
[Termination (ms): Min: 0.0, Avg: 6.5, Max: 8.7, Diff: 8.7, Sum: 51.9]
[GC Worker Other (ms): Min: 0.0, Avg: 1.5, Max: 3.0, Diff: 2.9, Sum: 11.9]
[GC Worker Total (ms): Min: 8.5, Avg: 17.9, Max: 29.8, Diff: 21.3, Sum: 143.2]
[GC Worker End (ms): Min: 6002870.4, Avg: 6002871.9, Max: 6002873.3, Diff: 2.9]
[Code Root Fixup: 0.1 ms]
[Code Root Migration: 1.1 ms]
[Clear CT: 2.4 ms]
[Other: 35.6 ms]
[Choose CSet: 0.0 ms]
[Ref Proc: 18.4 ms]
[Ref Enq: 0.0 ms]
[Free CSet: 16.9 ms]
[Eden: 5433.0M(5433.0M)->0.0B(5430.0M) Survivors: 1024.0K->1024.0K Heap: 9010.7M(10192.0M)->3577.9M(10192.0M)]
[Times: user=0.13 sys=0.01, real=0.07 secs]
Heap
garbage-first heap total 10436608K, used 6181542K [0x0000000575a00000, 0x00000007f2a00000, 0x00000007f5a00000)
region size 1024K, 2460 young (2519040K), 1 survivors (1024K)
compacting perm gen total 52224K, used 51927K [0x00000007f5a00000, 0x00000007f8d00000, 0x0000000800000000)
the space 52224K, 99% used [0x00000007f5a00000, 0x00000007f8cb5e30, 0x00000007f8cb6000, 0x00000007f8d00000)
No shared spaces configured.
That's the last log before the application stop running (The process is done). When I use top
command on the machine I always see 10G for the process I guess that's the effect of Xmx
option. But if I know how much it actually uses I can adjust and lower it down. So, I'll have more room for other processes. Please let me know if any other log you want to see.
Upvotes: 1
Views: 1293
Reputation: 43042
Instead of attempting to determine the minimum necessary heap size you can let the JVM yield memory back to the OS dynamically, possibly at the expense of a little reduced throughput.
Setting a tight limit of heap size ≈ live data set
is a very bad idea. It will either cause excessive garbage collections because it will just fill up very quickly or it will outright lead to OOMEs when your workload varies and it momentarily needs some more memory.
You also seem to care about pause times, the collectors may use extra memory beyond the live data set to meet those goals. If there's not enough spare capacity for G1 to do its work concurrently it will have to fall back to a full GC.
Upvotes: 2
Reputation: 5784
It is right here: total 10436608K, used 6181542K
. So by the time of this line your application used around 6G of heap
Upvotes: 1