find memory allocated between time A and time B which remains unfreed at time C

Viewed 204

I know that Visual Studio allows you to compare memory between two time snapshots in order to find leaks, using the debugger-integrated Memory Usage diagnostic tool. However is there a way to filter out of the diff any memory that was allocated after another time point (B) between start time (A) and end time (C) ?

Time A = start caring about memory that gets allocated

Time B = stop caring

Time C = all memory that was allocated between Time A and Time B should now be freed; if not, let's see the callstack that allocated each chunk

This does not necessarily need to be done using Visual Studio interactive diagnostics tool if is there for example a way to do this using _CrtMemCheckpoint instead or another way.

Although I have tagged this as a Visual Studio 2019 question, I will accept any solution that uses freely available Microsoft tools such as WinDbg or Free Open Source tools such as VLD (Visual Leak Detector) to achieve the same result.

1 Answers

Assuming the target platform is Windows since VS2019 is mentioned, I've found a tool similar to what you are looking for. https://www.codeproject.com/Articles/11221/Easy-Detection-of-Memory-Leaks

It is pretty old but still compiles.

Code from MemoryHooks can be used for new/delete override implementation. (void* operator new (std::size_t count ); and void operator delete (void* ptr);)

Related