Weak References and the GC

I'm developing a client for a server, and there are times when I need to refresh some data from the server. I was thinking about putting this data in a WeakHashMap because I only need it during the display of one dialog. The data takes up a large amount of memory, and I don't want to hang onto it for a long time if it is not needed so I don't have to keep going to the server to get the list everytime. However, if I'm running low on memory I don't mind if it is GC'ed. But, looking at the docs for WeakHashMap it gives me a bad feeling because half of the Map could be GC'ed and things like that.

Is there an precedence for Weak References? Does the GC only get rid of them if it only needs more memory? Does it try zero-referenced items first then goes after Weak References?

thanks

charlie

[840 byte] By [charlie76] at [2007-9-26 4:56:10]
# 1
Well, you can always create an ordinary HashMap and reference THAT with weak reference... that way, it will go away as a whole :)
mamlason at 2007-6-29 18:50:20 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
Objects that are weakly reachable are garbage collected as soon as they are encountered by the g.c. Unlike the sofly reacheable that could be collected if the g.c. encounters them and there is no a sortage of memory. If there is a sortage of memory sofly reacheable should be collected
Botella at 2007-6-29 18:50:20 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
What's is sofly references? I'm not familiar with that. There is no guarentees as to Weak References being given some VIP status by the GC so that they'll be only collected when it's absolutely necessary?charlie
charlie76 at 2007-6-29 18:50:20 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 4
Yes the sofly reacheble objects will be collected when the g.c. runs and there is memory sortage. For more on reference objects look at Bill Venners` artima.com
Botella at 2007-6-29 18:50:20 > top of Java-index,Java HotSpot Virtual Machine,Specifications...