JDK-8020943 : Memory leak when GCNotifier uses create_from_platform_dependent_str()
  • Type: Bug
  • Component: core-svc
  • Sub-Component: java.lang.management
  • Affected Version: fcs7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-07-19
  • Updated: 2014-02-07
  • Resolved: 2013-08-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8 Other
7u40Fixed 8Fixed hs24Fixed
In jdk7 onwards, running an application and attaching jconsole activates GC Notifications in the GC MBean.

There is some overhead accounted for by ArrayNotificationBuffer, but this should stabilise.  But there remains a JNI Handle leak that can be shown with -XX:+TraceJNIHandleAllocation.

"Unreferenced" java.lang.String objects accumulate in the heap, they are the Strings from the GC name/cause, and cannot be collected.

Going ahead with the change of the function call to avoid the leak, as it's unnecessary for the gcnotifier's strings, but following up with a separate bug on the actual leaked handle.

Reproducing the leak with a simple test app that causes a lot of collections, and attaching jconsole, the leak is clear. Testing a hotspot build where in void GCNotifier::sendNotificationInternal we replace: Handle objName = java_lang_String::create_from_platform_dependent_str(request->gcManager->name(), CHECK); with: java_lang_String::create_from_str(...) ...and my test app has a stable heap, no leak (expect heap usage around 7.5MB to account for the ArrayNotificationBuffer).