Question

We have several after effects plugins that we have good evidence are leaking memory. To investigate this, I am playing around with Memory Leak Detection and Isolation in the vcc compiler/runtime. I enabled leak detection with:

#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>

And I get a nice dump of leaks. However, I don't get file names and line numbers. My best guess is that this is because I'm building a dll, which is consumed by the after effects exe, and the #define needs to be made in the executable, not my plugin (this doesn't entirely fit with my mental model of what this define and includes actually do, but it's the best I can come up with).

So the other option is setting breakpoints for specific memory allocation numbers. However, the leaking allocations aren't a set of consistant allocation numbers, so I'm having limitted success with that.

So, any ideas here? Either how to better use this tool, or other ways to investigate this? Thanks!

Was it helpful?

Solution

You do have to recompile those DLLs with the same #defines - they turn calls to malloc() into calls to malloc_dbg() and this enables filenames and line numbers in the dump. That's all the "leak detection" does - each allocation is passed the filename and line number and they are stored and later dumped. No calls to malloc_dbg() - no filenames and no line numbers.

Also leak dumps (all related functions) are per-runtime - the dump is done for the heap of the current module runtime, not necessarily for all modules. Since you might have several C++ runtimes in your process (each DLL can be linked against its own runtime) it might happen that the dump is simply not done for the runtime you expect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top