Do you know if the reference is in the object itself - as you might have for a static 
reference to a singleton, can it be garbage collected?
Thanks
                                                                                       
                                  
                      Kevin Mukhar                                                     
                                  
                      <kmukhar@earthli         To:      "JDJList" 
<[EMAIL PROTECTED]>                          
                      nk.net>                  cc:                                     
                                  
                                               Subject: [jdjlist] Re: Heap Size of the 
JVM                               
                      06/25/2002 07:58                                                 
                                  
                      PM                                                               
                                  
                      Please respond                                                   
                                  
                      to "JDJList"                                                     
                                  
                                                                                       
                                  
                                                                                       
                                  



Java exams wrote:
>
>-- Narasimhan Sethuraman <[EMAIL PROTECTED]> wrote:
> > Setting objects as null will make the object
> > eligible for GC
>
> That should read "may make".  If there are other
> references to the object ( perhaps another reference
> to the exists in a Hashmap or Hashtable somewhere ),
> it will only be eligible once all references to the
> object have been cleared ( otherwise the object is
> "retained" ).

Actually, to be precise, the object becomes eligible for garbage collection when
it becomes unreachable. One way to do this is to remove all references to the
object. However, to use your example, one can have a reference stored in a
Hashmap that is non-null, yet if all references to the Hashmap are removed, then
the object in the Hashmap is unreachable and thus also eligible for garbage
collection.

To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm






******************* PLEASE NOTE *******************
This message, along with any attachments, may be confidential or legally privileged.  
It is intended only for the named person(s), who is/are the only authorized 
recipients. If this message has reached you in error, kindly destroy it without review 
and notify the sender immediately. Thank you for your help.
**********************************************************


To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm

Reply via email to