On 29.05.2016 08:44, Alain Stalder wrote:
[...]
If I use a WeakHashMap or Collections.synchronizedMap(WeakHashMap)
instead of the map from the Spring Framework, classes are not
collectable in the script-running-use-case (OutOfMemoryError) unless I
replace klazz in ClassInfo with a WeakRefererence and then it becomes
(only) softly-collectable.

which is no wonder if the value strongly references the key

All in all, I think this means that universally weakly-collectable
Groovy classes are more of a dream at the moment, at least before a
Groovy 3, and the merge requests for GROOVY-7683 (weak reference to
Class in ClassInfo) and GROOVY-7646 (explicit cleanup after running
scripts in GroovyShell) seem to be the best that can be done at the moment?

at least the weak reference to Class in ClassInfo is something I think we can do without too much danger. Of course we may have to handle the case in which a ClassInfo still exists, but the class is collected...

As for the introspector. My suggestion would be to clean the introspector of the specific class at the end of MetaclassImpl#addProperties

PS: Just for fun, I wrote a version where the map from the Spring
Framework is using soft references for
java.*/javax.*/groovy.*/org.codehaus.groovy.* classes and weak
references for all others, and that passed all my test scripts.

yeah.... I think, that's not good enough for us. You can have extension methods to ther classes, so it is no good if these get collected without recovery for the extension methods

bye Jochen

Reply via email to