There are many ways to check programs for memory leaks. You end up with that list of pointers to leaked memory blocks, but is there a good way to find out more information for each block? For example: if I know that the object was a string, the actual string value could make finding the leak a lot easier.
Is there a backdoor into RTTI that makes that possible?
Problems to solve would be that by the time you get the pointers the runtime system is already in a state of shutdown and you get raw memory block pointers instead of pointers to objects (though in many cases that might be the same).
RTTI may not help you. RTTI only works if the classes have virtual methods, and not all allocations are of objects with virtual methods.
What you really need to do is have some way to attach a stack trace to your allocations. Then you can get information about where the memory was allocated. You'd look for a class constructor if it was objects that leaked memory.
Anyway, is there something like this out there? Yes. A free library for Windows is Visual Leak Detector. There are more fully featured commercial products (like Bounds Checker, and IBM's Rational Purify), but VLD works great. It's helped me countless times spot memory leaks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With