Hi List: Is there a method being called right befire an object is being garbage collected (finalized)? I see toFinalizeSend: to: with:, but I do not see any senders. thanks in advance!
On 26 August 2011 16:29, Alex Schenkman <alex@schenkman.info> wrote:
Hi List: Is there a method being called right befire an object is being garbage collected (finalized)? I see toFinalizeSend:Â to: with:, but I do not see any senders. thanks in advance!
Squeak finalization is a post-mortem finalization. The #finalize message are sent to executor object, which is often a shallow copy of the object which is died. -- Best regards, Igor Stasenko AKA sig.
Let's see if I get this right: obj := Object new. objExecutor := obj executor. obj := nil. Smalltalk garbageCollect. Will this execute the method finalize on objExecutor? Is this the way to use it? Thanks! On Friday, August 26, 2011 at 5:53 PM, Igor Stasenko wrote:
On 26 August 2011 16:29, Alex Schenkman <alex@schenkman.info (mailto:alex@schenkman.info)> wrote:
Hi List: Is there a method being called right befire an object is being garbage collected (finalized)? I see toFinalizeSend: to: with:, but I do not see any senders. thanks in advance!
Squeak finalization is a post-mortem finalization. The #finalize message are sent to executor object, which is often a shallow copy of the object which is died.
-- Best regards, Igor Stasenko AKA sig.
Hi Alex, Here what I understood: o := Object new. WeakRegistry default add: o. "a shallow copy of o is registered" o := nil. Smalltalk garbageCollect. "the shallow copy of o will receive the finalize message" Cheers, #Luc 2011/8/26 Alex Schenkman <alex@schenkman.info>
Let's see if I get this right:
obj := Object new. objExecutor := obj executor. obj := nil. Smalltalk garbageCollect.
Will this execute the method finalize on objExecutor? Is this the way to use it?
Thanks!
On Friday, August 26, 2011 at 5:53 PM, Igor Stasenko wrote:
On 26 August 2011 16:29, Alex Schenkman <alex@schenkman.info> wrote:
Hi List: Is there a method being called right befire an object is being garbage collected (finalized)? I see toFinalizeSend: to: with:, but I do not see any senders. thanks in advance!
Squeak finalization is a post-mortem finalization. The #finalize message are sent to executor object, which is often a shallow copy of the object which is died.
-- Best regards, Igor Stasenko AKA sig.
Luc won the prize :) Alex, you understood almost right, except a missing part of adding an object to weak registry: obj := Object new. objExecutor := obj executor.
WeakRegistry default add: obj executor: objExecutor. obj := nil. Smalltalk garbageCollect.
if you look at default implementation of #executor, it just does a shallow copy of receiver. This is why two lines: objExecutor := obj executor. WeakRegistry default add: obj executor: objExecutor. equivalent to just: WeakRegistry default add: obj On 26 August 2011 21:18, Luc Fabresse <luc.fabresse@gmail.com> wrote:
Hi Alex,
Here what I understood:
   o := Object new.    WeakRegistry default add: o. "a shallow copy of o is registered"    o := nil.    Smalltalk garbageCollect.    "the shallow copy of o will receive the finalize message"
Cheers,
#Luc
2011/8/26 Alex Schenkman <alex@schenkman.info>
Let's see if I get this right: obj := Object new. objExecutor := obj executor. obj := nil. Smalltalk garbageCollect. Will this execute the method finalize on objExecutor? Is this the way to use it? Thanks!
On Friday, August 26, 2011 at 5:53 PM, Igor Stasenko wrote:
On 26 August 2011 16:29, Alex Schenkman <alex@schenkman.info> wrote:
Hi List: Is there a method being called right befire an object is being garbage collected (finalized)? I see toFinalizeSend:Â to: with:, but I do not see any senders. thanks in advance!
Squeak finalization is a post-mortem finalization. The #finalize message are sent to executor object, which is often a shallow copy of the object which is died.
-- Best regards, Igor Stasenko AKA sig.
-- Best regards, Igor Stasenko AKA sig.
participants (3)
-
Alex Schenkman -
Igor Stasenko -
Luc Fabresse