#391 Weak references

helium Mon 3 Nov 2008

Just stumbled on this in the .Net implementation: pod.cs

// TODO - .NET does not have soft references, so how could
// we implement this?  See the Pod.java for the java impl.

Of course .Net has "soft references". They are called weak references.

That arises my question: Are weak/soft references planed for Fan in the future?

andy Mon 3 Nov 2008

Thanks for pointing that out helium, I'll add that to my todo list.

brian Mon 3 Nov 2008

That arises my question: Are weak/soft references planed for Fan in the future?

Since both platforms implement weak references as APIs, as soon as we have native library interop then Fan can use those APIs directly.

Of course it would also be nice to have a standard portable Fan API for weak references. I think that will definitely happen, but pretty low on my radar right now.

alexlamsl Mon 3 Nov 2008

Of course .Net has "soft references". They are called weak references.

Huh? I thought SoftReference and WeakReference are different things...

andy Tue 4 Nov 2008

Actually, I remember that now - yes they are a little different. At the time I couldn't turn up the equivalent of SoftReferences in .NET. If anyone knows otherwise, let me know.

helium Tue 4 Nov 2008

OK, you notice that I don't work in the Java world that often.

I thought about bumping the object somehow to max generation but I'm not sure how to do that. You could perhaps hold a strong reference to it, perform GC.MaxGeneration collects up to generation (GC.MaxGeneration - 1) and than keep only a week reference. That would push it to generation GC.MaxGeneration and keep other weak references to objects in generation GC.MaxGeneration alive (as you only collect up to generation (GC.MaxGeneration - 1)). But I don't think that's a good idea.

Hmm ...

Login or Signup to reply.