Weak references and garbage collection

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Weak references and garbage collection

Richard Sargent
Administrator
If I have a particular object which has only weak references to it, it will eventually get garbage collected. However, my question is about the actual sequence of operations.

For example, if I have two distinct weak references to my object, are they both released/dropped/whatever at the same time or could one weak reference be removed by the garbage collector while leaving the other weak reference in place?


All answers are welcome, but I'm really looking for John to provide the official facts. :-)


Thanks

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Weak references and garbage collection

Seth Berman
Hi Richard,

The happy path is that all weak refs (slots) to the object (with only weak refs remaining) will be nil'd out at the same gc round (i.e. during a scavange or ggc).  Severing a weak object reference is done as each (weak obj, slot id, finalized obj) tuple is successfully added to the finalization queue.

However, in the event that the finalization queue is full, some weak refs may be nil'd and others (after the queue becomes full) will be forced to retain the reference and will need to be processed again in a subsequent gc round.

Another situation I know of is during a global garbage collection where the inactive new space segment is used for queuing up refs to weak objects identified during the mark phase of ggc.  If this overflows, then subsequent weak objects will be added to the normal marking stack.

Maybe there are some additional situations I have overlooked, but I guess the answer is already...it depends:)  Hope this helps

-- Seth

On Wednesday, August 21, 2013 2:23:54 PM UTC-4, Richard Sargent wrote:
If I have a particular object which has only weak references to it, it will eventually get garbage collected. However, my question is about the actual sequence of operations.

For example, if I have two distinct weak references to my object, are they both released/dropped/whatever at the same time or could one weak reference be removed by the garbage collector while leaving the other weak reference in place?


All answers are welcome, but I'm really looking for John to provide the official facts. :-)


Thanks

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/groups/opt_out.