We are facing a strange memory leak issue in our application.

GC configuration: ParNew + CMS

A certain type of Objects are getting promoted to old generation too early and causing severe fragmentation issues.

  1. Survivor had enough space to accommodate these objects
  2. Ageing threshold is 15 cycles and no premature promotion happened based on that.

About those objects: These are proxy objects created using Java assist library.

Due to the unnecessary promotion of such objects, Old generation is getting polluted too soon and heavy fragmentation is happening.

Our observations:

  1. Object is getting allocated in eden only. No size related problem.
  2. Scope of the object is very less and it is eligible for GCing in the next minor gc.
  3. To ensure this, we printed few loggers in finalize() and observed that scope ends immediately after the request. Just after the first minor GC.

Note: finalize() is just added for tracking purpose. Even without finalize() old gen promotion happens.

  1. After a single minor gc:
  • expectation is that object is going to get cleared.
  • But the object is getting promoted to old generation. With the help of multiple heap dumps, we are able to track the object promotion to old generation.
  1. All such objects are getting accumulated in old gen and are GCed by old gen GC.
  2. This behaviour is seen only in production servers and not reproducible in test environments.

Kindly suggest on how to proceed further and fix this.

Another interesting update: With G1GC, the objects are getting cleared properly when G1GC is used. Checked with using finalize() method, after the first cycle, the object became unreachable. After the next minor cycle, the object was not there. With G1GC the issue is not there.

0

There are 0 best solutions below