hi all,
I thought I try to give an update on the ClassValue issue. Well.. my
first suggestion is to really not activate it by default. That is
because Classvalue has quite special semantics.
I am trying to explain them a bit here....
so let us define AV as the value computed by a ClassValue aClassValue
and aClass the class value we want an AV for.
so there is relation (aClass,aClassValue)-> AV
In this relation there will be a strong reference of aClass to AV.
aClass and aClassValue can be (in theory) collected independent of AV,
AV can only be collected after aClass or aClassValue have been
collected. Even if AV references aClass it can still be collected -
under conditions
No imagine AV is actually called ClassInfo and from our Groovy runtime
and aClass is Integer. Since it is a system class, aClass will be never
collected, since aClassValue is an instance of our runtime, its class
and ClassInfo will have the same class loader. As there is a strong
reference to ClassInfo, that ClassInfo instance will not be collected.
And as ClassInfo will stay loaded, so will any class of the groovy
runtime. And since the class value is usually in a static field, that
mean class value too. In conclusion that means the runtime will not be
unloaded at all, class space used up and the final is a OOME.
There is no chance our approach in the current implementation can work.
To avoid the problem we would have to do a lot of things. first of all,
we have to avoid having an AV, which is from our runtime. So at the very
least we would need something like a WeakReference<ClassInfo> computed
from the classvalue, instead of ClassInfo directly. Next we would have
to keep a list of ClassInfo to avoid their garbage collection right
away. And then we would have to find a way to remove entries from there
upon class removal.
And that´s not all of it :(
bye Jochen