网站首页  词典首页

请输入您要查询的函数:

 

术语 heapfree
释义 HeapFree
语法:
C++
BOOL WINAPI HeapFree(
__in HANDLE hHeap,
__in DWORD dwFlags,
__in LPVOID lpMem
);
HeapFree函数
释放的内存块分配一个由HeapAlloc或HeapReAlloc功能堆。
参数
hHeap [in]
阿堆句柄的内存块被释放。这是处理无论是HeapCreate或GetProcessHeap函数返回。
dwFlags [in]
堆自由选择。指定以下值覆盖相应的价值时,堆使用HeapCreate函数创建flOptions参数指定。
ValueMeaning
HEAP_NO_SERIALIZE
0x00000001Serialized访问将不会被使用。有关更多信息,请参见备注。
为了确保序列化的访问被禁用所有这个函数调用,指定在调用HEAP_NO_SERIALIZE的HeapCreate。在这种情况下,没有必要的补充规定,在此函数调用HEAP_NO_SERIALIZE。
不指定此值时访问进程堆。该系统可在应用中创建的过程中,如按Ctrl + C处理,即同时访问进程堆额外的线程。
lpMem [in]
一个内存块的指针被释放。这个指针返回的HeapAlloc或HeapReAlloc功能。如果该指针为NULL,则行为是不确定的。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。应用程序可以调用的扩展的错误信息GetLastError函数。
备注
您不应该提及任何内存已被HeapFree释放方式。之后,内存被释放,任何可能也已经一去不复返了信息。如果您需要的信息,不释放内存包含的信息。函数调用返回有关内存的信息(如HeapSize)可能不释放内存使用,因为它们可能返回假数据。调用HeapFree,先后两次在同一个指针可能会导致堆损坏,在随后的调用返回相同的指针两次HeapAlloc结果。
序列化,确保相互排斥的两个或多个线程试图同时分配或来自同一堆空闲块。有一个小的性能成本的序列化,但必须使用多线程分配时,从同一个堆的可用内存。设置HEAP_NO_SERIALIZE价值消除了堆相互排斥。没有系列化,两个或多个线程使用同一个堆句柄可能试图分配或释放内存同时,在堆可能滋生腐败。该HEAP_NO_SERIALIZE值,因此,可以放心使用只有在下列情况下:
这个过程只有一个线程。
这一进程的多个线程,但只有一个线程调用特定堆的堆函数。
这一进程的多个线程,并且应用程序提供了相互排斥的机制,以一个特定的堆。
实例
有关示例,请参阅使用过程堆。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
堆函数
HeapAlloc
HeapReAlloc
内存管理功能
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==HeapFree Function
Frees a memory block allocated from a heap by the HeapAlloc or HeapReAlloc function.
Syntax
C++
BOOL WINAPI HeapFree(
__in HANDLE hHeap,
__in DWORD dwFlags,
__in LPVOID lpMem
);
Parameters
hHeap [in]
A handle to the heap whose memory block is to be freed. This handle is returned by either the HeapCreate or GetProcessHeap function.
dwFlags [in]
The heap free options. Specifying the following value overrides the corresponding value specified in the flOptions parameter when the heap was created by using the HeapCreate function.
ValueMeaning
HEAP_NO_SERIALIZE
0x00000001Serialized access will not be used. For more information, see Remarks.
To ensure that serialized access is disabled for all calls to this function, specify HEAP_NO_SERIALIZE in the call to HeapCreate. In this case, it is not necessary to additionally specify HEAP_NO_SERIALIZE in this function call.
Do not specify this value when accessing the process heap. The system may create additional threads within the application's process, such as a CTRL+C handler, that simultaneously access the process heap.

lpMem [in]
A pointer to the memory block to be freed. This pointer is returned by the HeapAlloc or HeapReAlloc function. If this pointer is NULL, the behavior is undefined.
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. An application can call GetLastError for extended error information.
Remarks
You should not refer in any way to memory that has been freed by HeapFree. 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 as HeapSize ) may not be used with freed memory, as they may return bogus data. Calling HeapFree twice with the same pointer can cause heap corruption, resulting in subsequent calls to HeapAlloc 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.
Examples
For an example, see Getting Process Heaps .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
Heap Functions
HeapAlloc
HeapReAlloc
Memory Management Functions
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa366701(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:17:36