aspose file tools*
The moose likes Beginning Java and the fly likes Collection: Understanding WeakHashMap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Collection: Understanding WeakHashMap" Watch "Collection: Understanding WeakHashMap" New topic
Author

Collection: Understanding WeakHashMap

Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
For the following example am I correct in saying that the assertion can fail,
because the WeakHashMap referenced by m2 could lose its contents, if there is some massive garbage collection taking place?

Thanks
-Barry


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Yes. if the WeakHashMap contains the only reference to an object, then that object is eligible for GC.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Collection: Understanding WeakHashMap
 
Similar Threads
Instantiated interface Collection
MasterExam question
Generics
Removing items in an iterator
Set issue.