JDK-8136973 : Unreachable classes are not deleted after the end of Conc Mark Cycle
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Not an Issue
  • Submitted: 2015-09-22
  • Updated: 2016-05-31
  • Resolved: 2016-05-31
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 9
9Resolved
Related Reports
Relates :  
Description
According JDK-8049421 G1 is able to unload unreachable classes at the remark pause. 
I attached a test which shows that unreachable classes are unload only after full gc, but not after ConcMarkCycle.

The test does the following:
1, compiles SimpleClassLoader which loads classes with specified name <prefix>, other classes are loaded by parent Class Loader
2. compiles ChildClassLoader which extends SimpleClassLoader
3. compiles <prefix>BaseClass and (<prefix>TestClass extends <prefix>BaseClass)
4. loads <prefix>TestClass using ChildClassLoader
5. forgets all links to classes and both classloaders
6. in case of full gc unreachable classes and ChildClassLoader are unloaded.
7. in case of ConcMarkCycle unreachable classes and ChildClassLoader are not unloaded.
Comments
I think this is a test bug. If the either of the class or the class loader stays in the the young gen, we won't be able to unload the class. You need to make sure that they get promoted to old gen, before you start the concurrent cycle.
07-04-2016

Eric, I tried but unfortunately b20 don't have White Box youngGC() method and b40 don't have g1StartConcMarkCycle() method. The testcase fails on b60. Regards, Kirill
24-09-2015

Hi Kirill, Please try your test against the original 9 builds with this feature to see if this is a test issue or feature regression. AFAICT this feature appeared around 9 build 26 or so. Thanks, Eric
23-09-2015

ILW - M(possible regression in class unloading?) M (full gc class unloading works ok) L (full gc class unloading works ok) -> P4
23-09-2015