I wasn't suggesting using them because they're sexy.  Personally, I don't use 
Reference objects unless they can't be avoided.  However, collections that use 
WeakReferences can be a serious help.  Essentially, they can help ensure object 
cleanup in a more timely fashion than traditional techniques, as an object placed in, 
say, a WeakHashMap will automatically be garbage collected when the only reference to 
the object is in the WeakHashMap.  It's a natural safeguard against someone forgetting 
to dereference an object in a Collection when they're done with it, which results in 
memory leakage.

Again, not being a FOP code veteran, I don't know where the points of use might be, 
but Reference objects and the "weak collections" seem to be a part of the Java API 
that don't get much coverage, so I wasn't sure if anyone had even considered their use.

-----Original Message-----
From: Jeremias Maerki [mailto:dev.jeremias@;greenmail.ch]
Sent: Thursday, November 07, 2002 8:51 AM
To: [EMAIL PROTECTED]
Subject: Re: HashMaps (WAS:RE: interface instead of implementation)


I didn't intend to kill that discussion with my response. I'm not a
specialist on those Reference classes but I've heard enough to say that
it can be tricky and should probably not be used just because it's sexy.
I'd vote for not using them unless there is a real good reason. I'm not
sure about your use case, but you might just have to do some research.
I'm sorry not to be more of a help.

Here's one URL describing the stuff in short. I'm sure there are better
ones.
http://developer.java.sun.com/developer/TechTips/1999/tt0511.html#tip2

On Thu, 07 Nov 2002 09:54:51 +1000 Peter B. West wrote:
> I was hoping there might be a little more detailed discussion here.  I 
> have no experience of WeakHashMaps or the various Reference objects, but 
> I have been thinking about using Reference objects, rather than direct 
> references, to point to the Nodes in my Tree, with the idea that at 
> least the first iteration in a cache/retrieve cycle on a subtree could 
> be handled transparently within the Tree.


Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to