Question about JEP 371 and unloading Lambdas

Mandy Chung mandy.chung at
Tue Jun 9 18:48:39 UTC 2020

Hi Thomas,

On 6/9/20 1:46 AM, Thomas Stüfe wrote:
> Hi,
> I currently try to understand how metaspace usage of Lambda proxies is
> affected with JEP 371. Could you please confirm if my understanding is
> correct:
> Lambdas live as long as the lookup class lives, which would be the class
> containing the lambda expression.

Yes the current implementation [1] defines the lambda proxy class as a 
hidden class with strong link to its defining loader.
> As for storage of metadata, in older JDKs Lambdas used anonymous classes,
> which meant each lambda class had its own associated CLD. Since JEP 371
> (?), the lambda class seems now directly associated with the CLD of the
> loader of the lookup class.

> So, metaspace storage is more efficient since
> we reuse the existing metaspace arena of the loader.

AFAICT less potential metaspace storage fragmentation.

> I guess this makes
> sense if the lifetime of the lambda is bound to that of the lookup class
> anyway, since that won't be unloaded until its loader goes away (or, if it
> itself is a hidden class, its CLD).
> Have I got this right?

You got this right.

I love to get your confirmation if  you have also observed the metaspace 
storage more efficient after JEP 371 integration.

> Thank you!
> Thomas


More information about the hotspot-runtime-dev mailing list