[
https://issues.apache.org/jira/browse/GROOVY-8092?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15884548#comment-15884548
]
John Wagenleitner commented on GROOVY-8092:
-------------------------------------------
For default metaclasses {{ClassInfo}} [keeps a soft reference to
it|https://github.com/apache/groovy/blob/6120cedb5e24aa54b06fdb0ff880ba24018d3525/src/main/org/codehaus/groovy/reflection/ClassInfo.java#L214-L223]
and {{MetaClassImpl}} (the default) [keeps a strong reference to the
Class|https://github.com/apache/groovy/blob/6120cedb5e24aa54b06fdb0ff880ba24018d3525/src/main/groovy/lang/MetaClassImpl.java#L128].
This in turn will prevent the ClassInfo from being collected until the GC
needs to reclaim memory. Since the MetaClass and some of it's data structures
(CachedClass, MetaMethodIndex.Header) were designed around referencing a class,
using a soft reference was probably the best alternative available but has the
side affect of requiring memory pressure to have clean up performed.
Some thoughts have I had in this area is that it would be good to reduce the
number of WeakReferences. I think {{ClassInfo}} could be changed to keep
strong references to classes if it's classloader is the same as or a child of
the class' classloader (or if the class' classloader is null), otherwise hold
it weakly. Then instead of passing the class the metaclass would keep a ref to
the ClassInfo that created it, accessing the class via the
{{ClassInfo#getTheClass}} method. But this would require changes to
public/protected methods/fields, so probably best left till a new metaclass
system is introduced.
> Compatibility issues between groovy 2.4.8 and jenkins workflow-cps-plugin
> 2.23
> -------------------------------------------------------------------------------
>
> Key: GROOVY-8092
> URL: https://issues.apache.org/jira/browse/GROOVY-8092
> Project: Groovy
> Issue Type: Bug
> Components: groovy-runtime
> Affects Versions: 2.4.8
> Environment: Jenkins 2.19-stable with a single commit that bumps
> groovy 2.4.8
> workflow-cps-plugin 2.23
> Reporter: Ion Alberdi
>
> Created the issue on jenkins first
> https://issues.jenkins-ci.org/browse/JENKINS-42189
> Creating it here, in case the fix may be developed in groovy itself.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)