您的位置:首页 > 移动开发

_CrtIsValidHeapPointer(pUserData)可能的原因(转)

2010-01-07 18:40 411 查看
I read the dbgheap.c and find the line 1132, it's as follows:
/*
* If this ASSERT fails, a bad pointer has been passed in. It
may be
* totally bogus, or it may have been allocated from another
heap.
* The pointer MUST come from the 'local' heap.
*/
1132: _ASSERTE(_CrtIsValidHeapPointer(pUserDat
a));

I also use google to find some answers.
They said
(1) If you are developing multithread application, be sure to link it
with the correct runtime library(/MD, /MT). That what
"The pointer MUST come from the 'local' heap." means.
Check what "ruintime library" you use. It should be "Multi threaded (
debug ) DLL"

(2)
Not only must they match, they must both be DLL versions. If they're
static versions, each piece (the exe and the dll) will have their own
heap and the OP will still be deleting from mismatched heaps.
I'd also be suspicious of general design issues given the way the OP's
main program is having to clean up for the dll.

You'll get this problem if you use two different run-time libraries,
one to allocate the memory and one to de-allocate the memory. Open up the
project settings dialog, switch to C/C++ tab, set Category to Code Generation and check the Use run-time library combo box. These must match in any modules that share the task of allocating and destroying memory.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: