Any way to track memory allocations?

Sean Kelly sean at invisibleduck.org
Wed Feb 25 08:55:11 PST 2009


Jarrett Billingsley wrote:
> On Tue, Feb 24, 2009 at 12:00 PM, wade Shen <swadenator at gmail.com> wrote:
> 
>> Is there a way to track down where memory is being allocated if I'm using phobos? Any recommendations would be appreciated.
> 
> This is something I have *always* wanted.  Unfortunately I don't think
> it's possible to add such instrumentation without modifying and
> recompiling Phobos.  Even if you're using D2, which uses druntime,
> there's no such thing.

This has been on my "to do" list forever.  One of these days I'll 
actually get to it :-)

> Hm, actually..
> 
> If you *are* using D2, you might be able to replace the GC interface
> with a "debug" interface that just forwards calls to the normal GC.
> This is a capability druntime inherited from the Tango runtime - the
> GC is separated from the rest of the standard library and can actually
> be replaced at link-time.  I don't know if D2 links all three parts of
> druntime into a single library or not, though.

It does.  Partially because the three-library approach seems to have 
problems on Linux (there are link errors even though everything needed 
is actually present).  But the GC is still easily replaceable.  In fact, 
D2 provides an undocumented way to redirect GC calls, but I don't think 
it will currently work for this form of interception--you'd end up with 
an endless loop.



Sean


More information about the Digitalmars-d-learn mailing list