HeapFree
来源:互联网 发布:淘宝招聘在家兼职客服 编辑:程序博客网 时间:2024/06/07 16:14
HeapFree
释放由HeapAlloc或 HeapReAlloc 函数从堆分配的内存块。
BOOLHeapFree(
HANDLEhHeap,
DWORDdwFlags,
LPVOIDlpMem
);
Parameters
hHeap
[in] 将要被释放的内存块的堆的句柄。该句柄由HeapCreate或 GetProcessHeap函数返回。
dwFlags
[in] 堆释放选项。当使用HeapCreate函数创建堆时,选用以下值来覆盖相应的在flOptions中指定的值。
Value
Meaning
HEAP_NO_SERIALIZE
0x00000001
序列化访问时将不会被使用,更多的信息参看 Remarks。
为了确保对于这个函数所有调用的序列化访问不可用, 在 HeapCreate的调用中指定 HEAP_NO_SERIALIZE。 在这种情况下,不需要在这个函数额外的指定 HEAP_NO_SERIALIZE。
当访问进程堆时,不要指定这个值。系统会在应用程序的进程中创建额外的线程,例如一个CTRL+C句柄,同时的访问这个进程堆。
lpMem
[in] 指向将要释放的内存块的指针。该指针由HeapAlloc或HeapReAlloc返回。
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. An application can callGetLastError for extended error information.
Remarks
You should not refer in any way to memory that has been freed byHeapFree. After that memory is freed, any information that may have been in it is gone forever. If you require information, do not free memory containing the information. Function calls that return information about memory (such asHeapSize) may not be used with freed memory, as they may return bogus data. CallingHeapFree twice with the same pointer can cause heap corruption, resulting in subsequent calls toHeapAlloc returning the same pointer twice.
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 to serialization, but it must be used whenever multiple threads allocate and free memory from the same heap. Setting the HEAP_NO_SERIALIZE value eliminates mutual exclusion on the heap. Without serialization, two or more threads that use the same heap handle might attempt to allocate or free memory simultaneously, likely causing corruption in the heap. The HEAP_NO_SERIALIZE value can, therefore, be safely used only in the following situations:
· The process has only one thread.
· The process has multiple threads, but only one thread calls the heap functions for a specific heap.
· The process has multiple threads, and the application provides its own mechanism for mutual exclusion to a specific heap.
Example Code
For an example, seeAWE Example.
Requirements
Client
Requires Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95.
Server
Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Header
Declared in Winbase.h; include Windows.h.
Library
Link to Kernel32.lib.
DLL
Requires Kernel32.dll.
See Also
Heap Functions,Memory Management Functions,GetProcessHeap,HeapAlloc,HeapCreate,HeapDestroy,HeapReAlloc,HeapSize,SetLastError
- HeapFree
- retval =HeapFree(_crtheap, 0, pBlock);异常断点
- 2014-03-16周日:内存释放函数HeapFree()
- GlobalFree HeapFree LocalFree与C函数free的区别与联系
- 当企图delete没有分配内存的指针时,会在这里HeapFree处异常
- 2014-03-13周四:内存释放函数HeapFree ()内存开辟函数HeapAlloc重新开辟函数HeapReAlloc
- 线程安全:分配堆与内存 API:HeapCreate HeapAlloc HeapSize HeapFree HeapDestroy
- free 一个指针时【 retval = HeapFree(_crtheap, 0, pBlock);】报错的原因
- win32api函数中heapalloc和heapfree使用导致内存没正常释放
- 【转】xfce4桌面自动整理脚本
- androidUI设计之旅 ----ViewPager的基本应用
- C语言(奇数和)
- 去除字符串首尾空格
- 聚类算法 K-means
- HeapFree
- 【黑马程序员】C#之冒泡排序
- 纯JS弹窗,没考虑兼容性,重用性,顺手写的
- java中为什么非静态嵌套类不能有静态变量?&& Thinking Java内存分配、管理总结
- ADO.NET实现CRUD
- hadoop之hadoop_eclipse_plugin编译和配置
- Java桌面程序打包成exe可执行文件
- Hibernate OpenSessionInView
- 输出等边三角形