_CrtMem* and the debug heap
When I use the following code, it detects a memory leak. How can I make it not?
_CrtMemState startState;
_CrtMemState endState;
_CrtMemState temp;
_CrtMemCheckpoint(&startState);
const char* foo = "I'm not leaking memory! Stop saying I am!";
_CrtMemCheckpoint(&endState);
_CrtMemDifference(&temp, &startState, &a开发者_StackOverflow社区mp;endState); // Returns true. Wtf?
I cut and pasted your code and tested it on my machine under VS2008 and _CrtMemDifference returns 0 ...
As the oft heard adage goes: "Works on my machine" ;)
Edit: Have you got multiple threads running? Is it possible another thread has allocated something between the 2 _CrtMemCheckpoint calls?
精彩评论