Search code examples
javagarbage-collectionjprofiler

What does JProfiler "Run GC" button uses to clean garbage compare to regular GC tuning being done by JVM


I have java enterprise application which is consuming more memory since few days, even though GC is running and we have adequate parameters set (ConcMarkSweepGC) it is not freeing complete memory.

When I have attached JProfiler, it is observed that whenever GC is running it is only clearing lets say if it was consuming 9GB, only around 1 to 1.2 GB is getting cleared. At the same time if I click on "Run GC" button attached with JProfiler it clears atleast 6-7 GB out of 9 GB occupied.

I was trying to understand what extra does Jprofiler GC does compare to regular GC executed by the application.

Following are few of the details required: - App server: Wildfly 9 - Java version: Java 8 - OS: Windows 2012 - 64Bit

Any help around this would be helpful. Thanks in advance.


Solution

  • The behaviour varies between different GC algorithms but in principle a GC on the Old Space is not supposed to clear all unused memory at all times. In New Space we see a copying parallel GC to combat memory fragmentation but the Old Space is supposed to be significantly larger. Running such a GC would result in a long stop-the-world pause. You selected ConcMarkSweepGC which is a concurrent GC that won't attempt to execute the full stop-the-world GC cycle if there is enough free memory. You probably initiated a full stop-the-world GC on the Old Space with JProfiler.

    If you want to understand it in detail read about different GC algorithms in JVM. There is quite a few of them and they are designed with different goals in mind.