ZGC Class Unloading in JDK11

Erik Osterlund erik.osterlund at oracle.com
Thu Jun 24 07:05:06 UTC 2021


Hi Roy,

Regarding your question, it all depends on whether your application uses ClassLoader instances to dynamically load and unload classes. If it does not, then class unloading will not be needed. Conversely, if the application does use ClassLoader instances in such a way, then it will have a memory leak that will make metaspace slowly grow. How long it takes until it blows up depends on the application behaviour.

Having said that, you could run a later release such as JDK 16, where ZGC is a supported production feature, to avoid that. The typical advantage of staying on an LTS release is that it is stable and gets supported for a long term when things break. However, ZGC was experimental back in 11, and is hence not supported at all in that release. So for experimental features, the LTS letters don’t mean much at all. In fact it is known to have a bunch of stability issues, and they will not be fixed due to the experimental status. In other words, using an experimental and hence unsupported feature in an LTS release (e.g. ZGC on 11) instead of a supported production feature in the non-LTS release train (e.g. ZGC on 16), only has the added advantage of having the letters “LTS” in the name. Otherwise the implications in terms of stability and support, are the exact opposite. By running ZGC on JDK 11 instead, you ensure that what you are running is not stable, will never be fixed and shouldn’t be used in production, compared to JDK 16 where it is stable, issues do get fixed, and is suitable for production.

Some people have strict company policies saying only releases with the magic LTS letters are to be used, no matter what. If you work for such a company, and hence really can’t use a non-LTS JDK, then I would probably just sit tight and wait for JDK 17 which is just around the corner at this point. 14th of September it says in the release schedule.

Hope this help!

/Erik

> On 24 Jun 2021, at 02:17, Roy Zhang <roy.sunny.zhang007 at gmail.com> wrote:
> 
> Dear ZGC experts,
> 
> As we know, regarding ZGC on JDK11, it doesn't support class unloading, it
> would be a bit challenging for metaspace sizing, i.e, how much native
> memory I need to prepare for metaspace.
> 
> Do you have any suggestions?
> 
> Really appreciate your great help in advance!
> 
> Thanks,
> Roy


More information about the zgc-dev mailing list