how to use GC as a leak detector? i.e. get some help info from GC?

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Sun May 24 14:40:17 PDT 2009


nobody wrote:
> == Quote from Jason House (jason.james.house at gmail.com)'s article
>> Why not use valgrind? With the GC disabled, it should give accurate results.
> 
> Strange enough, indeed I have tried valgrind with the GC disabled version.  It
> didn't report anything useful.
> 
> That's why I'm puzzled, does D's GC do something special?

The GC allocates memory directly from the OS, it doesn't use malloc/free and 
friends. It does this even when the GC is "disabled", which just means the 
collections won't happen. (Disabling the GC doesn't change the method of allocation)
Valgrind probably doesn't detect those OS calls (and almost certainly doesn't 
know about the GC calls).

If you're using Tango, you can link to the 'stub' GC instead of the normal 
('basic') one. The stub GC doesn't actually collect, it passes calls on to 
malloc/calloc/realloc/free instead. That should make Valgrind work.
(something similar probably applies if you're using D2 with druntime)



More information about the Digitalmars-d mailing list