After about 16 hours of trying to figure out something I've come to reach a hypothesis...
When using CMemoryState (and its Checkpoint() and Difference()) functions, it effs up when you have a vector contained in it. Check out the following code:
The assertion is thrown in this case.. I was trying for many hours and I'm just ........ed for wasting my time thinking I had a leak in my code... Perhaps I am wrong, but I don't see how I could be with the simple, straight-forward code above.Code:CMemoryState oldMemState, newMemState, diffMemState; oldMemState.Checkpoint(); std::vector<TCHAR*> vect; newMemState.Checkpoint(); _ASSERTE (diffMemState.Difference( oldMemState, newMemState ) == FALSE);
This is just something to keep in mind if you ever try using CMemoryState to catch a memory leak.