Groups | Blog | Home
all groups > dotnet clr > september 2003 >

dotnet clr : Soft and weak references


Dmitry Shaporenkov
9/4/2003 1:10:49 AM
Hi all,

it seems for me that in Java world there is much freedom
in controlling the garbage collector than in .NET: JDK
includes SoftReference and WeakReference classes,
while .NET supports only WeakReferences. Is there any way
to simulate soft references in .NET? Or why they are
missed?

I'm not a guru in .NET garbage collector, and I have a
problem: in my Java application there is a cache based on
soft references, and all works fine. When I ported the
application to the .NET, the cache becomes using weak
references, and it's behavior is now far from good: weak
references die too often, so the application needs to
rebuild cached object which is time-consuming procedure.

Thanks in advance,
Jay B. Harlow [MVP - Outlook]
9/4/2003 9:48:08 AM
Dmitry,
For those of use not fluent in Java, can you explain (or give link) on what
a SoftReference is & how you would use it in your Cache?

Then I or someone else may be able to offer suggestions on how to better
approximate them in .NET.

At the very least it does sound like something I would find useful.

Hope this helps
Jay


[quoted text, click to view]

Jay B. Harlow [MVP - Outlook]
9/4/2003 9:59:22 AM
Dmitry,
Does the "Caching Application Block for .NET" give you closer to what you
want?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/CachingBlock.asp

Granted its not SoftReferences per se.

Hope this helps
Jay

[quoted text, click to view]

AddThis Social Bookmark Button