JDK-7044160 : Property argument processing leaks memory
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: hs21
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2011-05-12
  • Updated: 2017-08-01
  • Resolved: 2017-08-01
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 10
10Resolved
Related Reports
Relates :  
Description
From Roger Hoover at Apple

I recently fixed a bug in Apple's Java SE 6 hotspot introduced by merging 6u25, and since
open jdk7 has the same code ....

Back in 2005, Apple's performance team forced us to fix all memory leaks in Java.  One of
these fixes was to argument processing at the end of bool Arguments::add_property(const
char* prop):

--- Hotspot/trunk/src/share/vm/runtime/arguments.cpp
+++ Hotspot/trunk/src/share/vm/runtime/arguments.cpp
@@ -813,4 +813,8 @@
   // Create new property and add at the end of the list
   PropertyList_unique_add(&_system_properties, key, value);
+  FreeHeap(key);
+  if (eq != NULL) {
+    FreeHeap(value);
+  }
   return true;
 }

Unfortunately, the hotspot in the 6u25 update makes a change that relies upon this leak.
(Not that PropertyList_unique_add copies key and value):
@@ -927,9 +992,7 @@
   } else if (strcmp(key, "sun.java.command") == 0) {
     _java_command = value;

-    // don't add this property to the properties exposed to the java application
-    FreeHeap(key);
-    return true;
+    // Record value in Arguments, but let it get passed to Java.
   } else if (strcmp(key, "sun.jva.launcher.pid") == 0) {
     // launcher.pid property is private and is processed
     // in process_sun_java_launcher_properties();

I changed the apple version to allocate new space for _java_command, but in jdk7 all
args that fall through to the end lead except for sun.java.command=command.

Comments
The code was re-written for 9, thus this is no longer an issue. Closing as NAI.
01-08-2017