sorry for answering so late...

Am 27.04.2013 23:54, schrieb John Rose:
[...]
> As a simple example:  Make a ClassValue object, bind a 1Mb array to
> Object.class using it, and then throw it all away.  (Except
> Object.class, naturally.)  Even if you do this in a loop, you should not
> get a storage leak.
 >
> (A class value bound to a class is live only if both the Class and the
> ClassValue instance are both live.)

sometimes it is like having bricks in front of your eyes ;) I think I 
understand now.

> Often people bind ClassValue instances to "static final" variables.  If
> the class containing the static variable goes away, then the ClassValue
> goes away, and anything bound (to whatever class, including Object)
> should go away.  That's nice, at least in theory.
>
> Things get tricky (this probably happens in practice) when there is a loop:
>
>    class MyRuntimeInMyClassLoader { static final MyClassValue MYCV = ...
> } => instance of MYCV
>    instance of MYCV x Object.class (say) => instance of MyMetaStuff
>    instance of MyMetaStuff => MyRuntimeInMyClassLoader.class
>
> Although I am not one of the 12 people on the planet who fully
> understand class loader interactions with GC, I suspect this loop might
> be "sticky", and might have to be broken by (say) a SoftReference.  (You
> can use a SoftReference if you are willing to have the GC break
> references not recently used, which you can reconstruct if needed.)

I think that is a case the GC has to resolve ;)

bye Jochen

-- 
Jochen "blackdrag" Theodorou - Groovy Project Tech Lead
blog: http://blackdragsview.blogspot.com/
german groovy discussion newsgroup: de.comp.lang.misc
For Groovy programming sources visit http://groovy-lang.org

_______________________________________________
mlvm-dev mailing list
mlvm-dev@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

Reply via email to