我试了. 确实不行, 不好意思 --------------------------- Microsoft Visual C++ Debug Library --------------------------- Debug Assertion Failed!Program: E:\PROC\KRH\VC\SDK\HeapTest\debug\HeapTestExe.exe File: dbgheap.c Line: 1044Expression: _CrtIsValidHeapPointer(pUserData)For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.(Press Retry to debug the application) --------------------------- 终止(A) 重试(R) 忽略(I) ---------------------------
另外既然是在同一个进程的地址空间里,又为什么不能跨模块删除内存呢?为什么要采用这个机制呢,是为了模块的保护吗?
return HeapAlloc( _crtheap, 0, size );
这里的_crtheap在每个DLL模块中都会有的,这样就说明每个模块的内存段实际上是自己管理的。这样你如果在其他模块中free了,由于_crtheap值不同,所以不能free其他模块的内存。
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!Program: E:\PROC\KRH\VC\SDK\HeapTest\debug\HeapTestExe.exe
File: dbgheap.c
Line: 1044Expression: _CrtIsValidHeapPointer(pUserData)For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.(Press Retry to debug the application)
---------------------------
终止(A) 重试(R) 忽略(I)
---------------------------
个人意见.期望高手做出正确解答.