groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <>
Subject Re: Improve Groovy class loading performance and memory management
Date Sun, 15 May 2016 10:37:47 GMT
On 15.05.2016 10:39, Alain Stalder wrote:
> Thanks, that clarifies a lot to me, especially SoftReference.
> So with Groovy it is only realistic to have GC of classes (and attached
> ClassInfo) kick in once a limit on Metaspace/PermGen (or Heap) is
> reached - fine with me, no point to try to "outrun the bear"... :)

well... I do think the ClassValue version should not have this 
behaviour. But for this I think we would have to ensure not to keep any 
references to the ClassValue anywhere in a global strucutre. Not even as 
a WeakReference... PhantomReference would probably be ok... but I find 
the usages for PhantomReferences quite rare...and not fitting here I guess

> A general question (current implementation and most likely APIs to keep
> aside): Why does ClassInfo need a reference to the class? To me the use
> case would be that you have an Groovy object or a Groovy class and want
> to do something with it (call a static or instance method, for example),
> so you only need to find ClassInfo from the class and then maybe pass
> the class temporarily just for doing things, but don't need it a
> reference back from ClassInfo.

ClassInfo represents a cached reflective information of a Class, plus 
some more internal stuff. To create that structure you need the Class. 
And if you do not want to do it eager, you need to keep a reference... 
at least till after init. Of course that does not have to be a 

> This allows, for example, two produce two of the known
> "OutOfMemoryError: Metaspace|PermGen" issues with Groovy 2.4.6, as follows.

good job

bye Jochen

View raw message