Hooking the GC?
Steven Schveighoffer
schveiguy at yahoo.com
Mon Jan 3 05:37:39 PST 2011
On Sun, 02 Jan 2011 22:34:55 -0500, %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.)
>
> Thank you!
If you want to hook the GC, you probably have to add your own code to the
GC.
Start with _d_newclass in druntime's src/rt/lifetime.d
-Steve
More information about the Digitalmars-d
mailing list