I've an application that's using an off-heap byte array to read data from and pushes it into a primitive (key and value) heap based Hashmap. I've allocated 4G to my application, running it for 10 minutes show 14MB of max heap usage, but within that 10 minutes I see a few young collections kicking in. These collections are running for handful of regions (6 - 8) only. I profiled it to see how much garbage my application is generating but it's less than 40MB in 10 minutes.
Is there a way, I can tell G1GC to not to kick young GC, because there is plenty of heap left. Probably, collect it lets say after 1GB or 50% of young generation usage, which I know my application would never hit? I tried the following:
- Increasing XX:G1NewSizePercent to 50% and it did make a difference but not enough. So instead of 10 collection I'm getting 5. But still 5 is too much in my case.
- Reducing pause time to 1ms.-XX:MaxGCPauseMillis
- Increasing concurrent thread to same number as my cores via XX:ConcGCThreads.
Example of GC logs:
101.211: [GC pause (G1 Evacuation Pause) (young) 101.211: [G1Ergonomics (CSet Construction) start choosing CSet, _pending_cards: 1030, predicted base time: 3.04 ms, remaining time: 46.96 ms, target pause time: 50.00 ms] 101.211: [G1Ergonomics (CSet Construction) add young regions to CSet, eden: 3 regions, survivors: 1 regions, predicted young region time: 1.03 ms] 101.211: [G1Ergonomics (CSet Construction) finish choosing CSet, eden: 3 regions, survivors: 1 regions, old: 0 regions, predicted pause time: 4.07 ms, target pause time: 50.00 ms] , 0.0010747 secs] [Parallel Time: 0.6 ms, GC Workers: 8] [GC Worker Start (ms): Min: 101210.9, Avg: 101211.0, Max: 101211.1, Diff: 0.1] [Ext Root Scanning (ms): Min: 0.2, Avg: 0.2, Max: 0.3, Diff: 0.2, Sum: 1.7] [Update RS (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.3] [Processed Buffers: Min: 0, Avg: 1.0, Max: 2, Diff: 2, Sum: 8] [Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0] [Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.2, Diff: 0.2, Sum: 0.2] [Object Copy (ms): Min: 0.0, Avg: 0.1, Max: 0.1, Diff: 0.1, Sum: 0.6] [Termination (ms): Min: 0.0, Avg: 0.1, Max: 0.1, Diff: 0.1, Sum: 0.7] [Termination Attempts: Min: 1, Avg: 1.0, Max: 1, Diff: 0, Sum: 8] [GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1] [GC Worker Total (ms): Min: 0.4, Avg: 0.4, Max: 0.5, Diff: 0.1, Sum: 3.5] [GC Worker End (ms): Min: 101211.4, Avg: 101211.5, Max: 101211.5, Diff: 0.0]