groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Wagenleitner <john.wagenleit...@gmail.com>
Subject Re: Improve Groovy class loading performance and memory management
Date Tue, 17 May 2016 19:51:25 GMT
On Tue, May 17, 2016 at 12:48 AM, Alain Stalder <astalder@span.ch> wrote:

>
> On 17.05.16 09:04, Alain Stalder wrote:
>
> PS: Note that Introspector.flushFromCaches(clazz) was experimentally
> really not necessary in this case, but maybe has to do with the simple
> nature of the test script ("42") and only calling a (no-args)
> constructor... In any case very promising...
>
>
> Ah, that's simply because it is already called in
> InvokerHelper.removeClass():
>
>     public static void removeClass(Class clazz) {
>         metaRegistry.removeMetaClass(clazz);
>         ClassInfo.remove(clazz);
>         Introspector.flushFromCaches(clazz);
>     }
>
> Experimentally, for the test with ClassGCTester, the first call
> (metaRegistry.removeMetaClass(clazz)) was not necessary to have garbage
> collection before Metaspace reaches the maximum, the other two were.
>
>

I believe the removeMetaClass call is only there in case the metaclass
changed.  Any added methods cause the weak metaclass to be replaced by a
strong metaclass (ExpandoMetaClass) and that has a strong ref to the class
requiring removing the metaclass in order to allow GC to work.

Mime
View raw message