HighTechTalks DotNet Forums  

java.lang.ref.SoftReference missing?

Dotnet VJSharp microsoft.public.dotnet.vjsharp


Discuss java.lang.ref.SoftReference missing? in the Dotnet VJSharp forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Nathan Baulch
 
Posts: n/a

Default java.lang.ref.SoftReference missing? - 03-08-2006 , 07:43 PM






I'm trying to compile a Java project in Visual Studio however it would seem
that J# doesn't have an implementation of the java.lang.ref.SoftReference
class (which I imagine would be a simple wrapper over the top of a
System.WeakReference).

I'm trying to keep the project as close as possible to pure Java (ie, only
reference vjslib.dll and not mscorlib.dll) however it looks like I'll have
to contaminate it by migrating the SoftReferences to WeakReferences.


Nathan



Reply With Quote
  #2  
Old   
Bruno Jouhier
 
Posts: n/a

Default Re: java.lang.ref.SoftReference missing? - 03-11-2006 , 10:32 AM






SoftReferences and WeakReferences have different semantics:

Objects referenced through weak references go away as soon as you don't have
any strong references to them (at the next GC pass).
Objects referenced through soft references go away when the memory starts to
fill up, if they don't have strong references pointing to them. So, they
don't go away at the next GC pass if the memory pressure is low.

So, soft references are much more practical than weak reference for caching,
and you will need to do some extra work (keeping extra strong references and
breaking them when memory pressure gets high) if you want to reproduce the
soft reference behavior with weak references.

2 reasons why J# does not have soft references:

* it is based on JDK 1.1.4, which did not have soft references.
* the .NET framework (even 2.0) only provides weak references.

Bruno

"Nathan Baulch" <nathan.baulch (AT) gmail (DOT) com> a écrit dans le message de news:
umxh5JxQGHA.1556 (AT) TK2MSFTNGP09 (DOT) phx.gbl...
Quote:
I'm trying to compile a Java project in Visual Studio however it would
seem that J# doesn't have an implementation of the
java.lang.ref.SoftReference class (which I imagine would be a simple
wrapper over the top of a System.WeakReference).

I'm trying to keep the project as close as possible to pure Java (ie, only
reference vjslib.dll and not mscorlib.dll) however it looks like I'll have
to contaminate it by migrating the SoftReferences to WeakReferences.


Nathan




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.