GC catcher

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

GC catcher

Luca Bruno aka Lethalman
Hello,
i was looking at various method and classes but i didn't find anything  
interesting about this question.
Is there a way to catch GC when deleting an object? Something like a  
method calling before deleting it...

Byte.

--
www.lethalman.net - Thoughts about computer technologies

Reply | Threaded
Open this post in threaded view
|

Re: GC catcher

stéphane ducasse-2
look for finalize

Object>>finalize
        "Finalize the resource associated with the receiver. This message  
should only be sent during the finalization process. There is NO  
garantuee that the resource associated with the receiver hasn't been  
free'd before so take care that you don't run into trouble - this all  
may happen with interrupt priority."


On 1 juin 06, at 21:26, Bruno Luca wrote:

> Hello,
> i was looking at various method and classes but i didn't find  
> anything interesting about this question.
> Is there a way to catch GC when deleting an object? Something like  
> a method calling before deleting it...
>
> Byte.
>
> --
> www.lethalman.net - Thoughts about computer technologies
>


Reply | Threaded
Open this post in threaded view
|

Re: GC catcher

Luca Bruno aka Lethalman
On Thu, 01 Jun 2006 21:55:29 +0200, stéphane ducasse  
<[hidden email]> wrote:

> look for finalize
>
> Object>>finalize
> "Finalize the resource associated with the receiver. This message  
> should only be sent during the finalization process. There is NO  
> garantuee that the resource associated with the receiver hasn't been  
> free'd before so take care that you don't run into trouble - this all  
> may happen with interrupt priority."
>
>

Thanks this time too man :)

--
www.lethalman.net - Thoughts about computer technologies

Reply | Threaded
Open this post in threaded view
|

Re: GC catcher

johnmci
In reply to this post by Luca Bruno aka Lethalman
Look in the archives for weak references and finalization.

On finalization a shadow copy of your object is sent a finalization  
method after the real object has been GCed.
Other smalltalks provide a number of solutions up to including  
sending a message to your object saying it's going to be GCed
and asking if it should be resurrected. (not a squeak solution).

Normally this logic is used to close system resources, say operating  
system file handles.

see
StandardFileStream>>actAsExecutor
 >>finalize

StandardFileStream class>>register:
unregister:
registry

for clues.

On 1-Jun-06, at 12:26 PM, Bruno Luca wrote:

> Hello,
> i was looking at various method and classes but i didn't find  
> anything interesting about this question.
> Is there a way to catch GC when deleting an object? Something like  
> a method calling before deleting it...
>
> Byte.
>
> --
> www.lethalman.net - Thoughts about computer technologies
>

--
========================================================================
===
John M. McIntosh <[hidden email]> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
========================================================================
===