Reputation: 21
I started my java application with option -Xmx20G, so it should be able to use up to 20GB heap memory. I connected jVidualVm and JMC to my application and can see that maximum of only 8GB memory is being used by application. Once the memory usage reaches around 8GB, garbage collection happens.
Please see the image
Memory usage as seen on JMC, the max heap memory can be seen as 20GB.
Any ideas why memory usage is not reaching around 20GB, before GC happens?
Upvotes: 0
Views: 648
Reputation: 718768
A typical Java heap is divided into a new space and old space. When the new space fills up, it is garbage collected. Since "most objects die young", and garbage is "less work" than non-garbage, the new space collector is fast ...
Objects that survive a few new space collections are moved to the old space (the technical term is "tenured"). When the old space starts to fill up, the old space collector is triggered. The old space collector is slower because the old space is typically larger, objects there tend to survive multiple GCs, and other factors.
So, looking at that graph, it appears that your JVM's new space is ~7GB and its old space is ~14GB. It looks like your application is generating garbage object steadily, and this is repeatedly triggering the new space collector. However, it looks like the new space collector is succeeding in almost emptying the new space. (Look how low the troughs in the graph ar4e. It looks like they drop to ~0.5MB.)
So the short answer is that your 20GB heap is not being fully used ... because it doesn't need to be used. It is over-sized for that application / workload.
Upvotes: 1
Reputation: 101
Try adding –XX:+DisableExplicitGC to your command line to check if this changes something.
Upvotes: 0