Debugging a Memory Leak
Etienne via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Nov 18 08:14:19 PST 2014
On 2014-11-17 6:12 PM, Maxime Chevalier-Boisvert wrote:
> Help or advice on solving this problem is welcome.
I've tried dumping logs from the garbage collection process and it's the
biggest waste of time. Even if you left a reference somewhere, the logs
will not help identify the code that caused it.
Instead, you should do a test with the following:
Store in a string[size_t] a list of pointers that should have been
collected, along with the variable name. Once you assume they should
have been collected, run this:
http://dlang.org/phobos/core_thread.html#.thread_scanAll
The thread_scanAll function will send you valid memory ranges in your code.
Run the stored size_t list against each value contained in the memory
range. Accumulate everything that matches into another hashmap, and then
fail with the error "Variables [list of identifiers] still have
references in the code!"
More information about the Digitalmars-d-learn
mailing list