JDK-8005602 : NPG: classunloading does not happen while CMS GC with -XX:+CMSClassUnloadingEnabled is used
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: hs25
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2012-12-29
  • Updated: 2013-04-30
  • Resolved: 2013-03-14
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 8 Other
8Fixed hs25Fixed
The expected behavior is that with CMS when the allocation of native memory reaches a certain value (the default value of MetaspaceSize) that a concurrent collection of the old generation will start and that classunloading will happen at the end of the concurrent collection of the old generation and native memory for class metadata will be reused. 
But classunloading does not happen.
I filed INTJDK-7602547 about -Xmn2m and -XX:+MaxMetaspaceSize keys.

The cause for this issue is actually a combination of some bugs: * When doing concurrent class unloading (-XX:+CMSClassUnloadingEnabled) we currently don't actually call "purge()" to release all the memory associated with the unloaded classes * When doing class unloading we sometimes compute the next size of metaspace before releasing the memory, thereby artificially inflating the size of metaspace memory * Relasing the memory doesn't currently hand the memory back to the OS, which can cause the VM to get a native-OOM when we've allocated too aggressively. inherent behavior in CMS: * CMS is and has always been unable to unload classes which are kept alive by objects in the young generation I plan to fix the first two points for this CR and the third point is a work-in-progress. In the meantime I suggest we should try to update the PCL tests to either: * Run with -XX:+MaxMetaspaceSize * Run with -Xmn2m if CMS is enabled. The second item would actually be valuable for JDK7u as well since running the PCL tests without -Xmn2m we don't actually trigger any CMS-classunloading, only full-stw-classunloading.

b58 is the first build of JDK 8 with NPG, so to determine if this is a NPG regression or not you would need to compare with 8-b57 or earlier.