异常发生在HeapFree函数体中
我正确的调用了HeapFree函数,但调试的时候发现,异常是发生在HeapFree函数体中的。这是怎么回事,如果HeapFree不成功就返回0啊,怎么会发生异常 问题点数:20、回复次数:4Top
1 楼snlux(snlux)回复于 2006-03-04 01:01:02 得分 0
有冲突嘛,仔细看看MSDN里的说明:)Top
2 楼LAssemblyL()回复于 2006-03-04 07:08:42 得分 0
Return Values
Nonzero indicates success.
Zero indicates failure.
To get extended error information, call GetLastError.
Remarks
Serialization ensures mutual exclusion when two or more threads attempt to simultaneously allocate or free blocks from the same heap. There is a small performance cost, but it must be used when multiple threads allocate and free memory from the same heap.
A critical section is always used to serialize access to an individual heap. There is a critical section per heap to protect access to each heap.
An attempt to grab a critical section that is not owned is a fast path operation that incurs little overhead. This is similar to using the HEAP_NO_SERIALIZE flag if only one thread was ever accessing a particular heap.
If there is contention for the critical section and therefore the heap, a new thread request to allocate heap space will serialize.
没看到提示说什么冲突,很简单的一个程序,单线程
Top
3 楼LAssemblyL()回复于 2006-03-04 23:06:53 得分 0
没人知道?Top
4 楼Snow_Ice11111(雪上加冰)回复于 2006-03-05 00:37:06 得分 0
不贴出分配和回收相关的代码让人家如何分析?Top




