Hooking the GC?

Simen kjaeraas simen.kjaras at gmail.com
Mon Jan 3 01:33:22 PST 2011


%u <wfunction at hotmail.com> wrote:

> Hi,
>
> Is there any way to add a hook to the garbage collector in D, so that I  
> can be
> immediately notified (for example) when an object is created?
>
> (I'm aware that this could cause infinite recursion/deadlock if I try to
> allocate memory, but that's all right, I'm fine with that.)

You're gonna have to add such functionality to the GC by yourself, I'm
afraid. Shouldn't be too hard though, depending on what sort of info you
require from the hook.


-- 
Simen


More information about the Digitalmars-d mailing list