Notification on GC of an object?

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

Notification on GC of an object?

jfabry
Hi all,

does anybody here have experience with hooking into the GC mechanism so that an object gets notified when it is collected? I have a setup here with auto generated classes that I would like to remove when their unique instance disappears. So I’d like to let the GC figure out all the complicated tracking and inform me whenever such an object is collected, then I’ll zap the class as well.

Experience reports, hints and tips are most welcome!

---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile


Reply | Threaded
Open this post in threaded view
|

Re: Notification on GC of an object?

Sven Van Caekenberghe-2
Object>>#finalize ?

> On 13 Jan 2015, at 15:13, Johan Fabry <[hidden email]> wrote:
>
> Hi all,
>
> does anybody here have experience with hooking into the GC mechanism so that an object gets notified when it is collected? I have a setup here with auto generated classes that I would like to remove when their unique instance disappears. So I’d like to let the GC figure out all the complicated tracking and inform me whenever such an object is collected, then I’ll zap the class as well.
>
> Experience reports, hints and tips are most welcome!
>
> ---> Save our in-boxes! http://emailcharter.org <---
>
> Johan Fabry   -   http://pleiad.cl/~jfabry
> PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Notification on GC of an object?

jfabry

No, just putting the cleanup code in a finalize method does not seem to be working, sadly.

> On Jan 13, 2015, at 11:18, Sven Van Caekenberghe <[hidden email]> wrote:
>
> Object>>#finalize ?
>
>> On 13 Jan 2015, at 15:13, Johan Fabry <[hidden email]> wrote:
>>
>> Hi all,
>>
>> does anybody here have experience with hooking into the GC mechanism so that an object gets notified when it is collected? I have a setup here with auto generated classes that I would like to remove when their unique instance disappears. So I’d like to let the GC figure out all the complicated tracking and inform me whenever such an object is collected, then I’ll zap the class as well.
>>
>> Experience reports, hints and tips are most welcome!
>>
>> ---> Save our in-boxes! http://emailcharter.org <---
>>
>> Johan Fabry   -   http://pleiad.cl/~jfabry
>> PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile
>>
>>
>
>
>



---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile


Reply | Threaded
Open this post in threaded view
|

Re: Notification on GC of an object?

Clément Béra
Yeah Object>>#finalize is supposed to do what you said but unfortunately it does not work...

Maybe it's a VM bug or maybe it's not supported any more. 

We'll see if Eliot answer the thread.

2015-01-13 15:55 GMT+01:00 Johan Fabry <[hidden email]>:

No, just putting the cleanup code in a finalize method does not seem to be working, sadly.

> On Jan 13, 2015, at 11:18, Sven Van Caekenberghe <[hidden email]> wrote:
>
> Object>>#finalize ?
>
>> On 13 Jan 2015, at 15:13, Johan Fabry <[hidden email]> wrote:
>>
>> Hi all,
>>
>> does anybody here have experience with hooking into the GC mechanism so that an object gets notified when it is collected? I have a setup here with auto generated classes that I would like to remove when their unique instance disappears. So I’d like to let the GC figure out all the complicated tracking and inform me whenever such an object is collected, then I’ll zap the class as well.
>>
>> Experience reports, hints and tips are most welcome!
>>
>> ---> Save our in-boxes! http://emailcharter.org <---
>>
>> Johan Fabry   -   http://pleiad.cl/~jfabry
>> PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile
>>
>>
>
>
>



---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile



Reply | Threaded
Open this post in threaded view
|

Re: Notification on GC of an object?

EstebanLM
In reply to this post by jfabry
you also need to register the object for cleanup, in the WeakRegistry.
(not on my machine, sorry I cannot put an example, but look around)

Esteban

> On 13 Jan 2015, at 11:55, Johan Fabry <[hidden email]> wrote:
>
>
> No, just putting the cleanup code in a finalize method does not seem to be working, sadly.
>
>> On Jan 13, 2015, at 11:18, Sven Van Caekenberghe <[hidden email]> wrote:
>>
>> Object>>#finalize ?
>>
>>> On 13 Jan 2015, at 15:13, Johan Fabry <[hidden email]> wrote:
>>>
>>> Hi all,
>>>
>>> does anybody here have experience with hooking into the GC mechanism so that an object gets notified when it is collected? I have a setup here with auto generated classes that I would like to remove when their unique instance disappears. So I’d like to let the GC figure out all the complicated tracking and inform me whenever such an object is collected, then I’ll zap the class as well.
>>>
>>> Experience reports, hints and tips are most welcome!
>>>
>>> ---> Save our in-boxes! http://emailcharter.org <---
>>>
>>> Johan Fabry   -   http://pleiad.cl/~jfabry
>>> PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile
>>>
>>>
>>
>>
>>
>
>
>
> ---> Save our in-boxes! http://emailcharter.org <---
>
> Johan Fabry   -   http://pleiad.cl/~jfabry
> PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile
>
>