开发者

_CrtMem* and the debug heap

开发者 https://www.devze.com 2022-12-17 09:14 出处:网络
When I use the following code, it detects a memory leak. How can I make it not? _CrtMemState startState;

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消