网站首页  词典首页

请输入您要查询的函数:

 

术语 heapcompact
释义 HeapCompact
语法:
C++
SIZE_T WINAPI HeapCompact(
__in HANDLE hHeap,
__in DWORD dwFlags
);
HeapCompact功能
返回的最大承诺在指定的堆空闲块的大小。如果对自由的全局标志禁用堆凝聚设置,这一功能还必合,在堆邻近的空闲内存块。
参数
hHeap [in]
阿堆句柄。这是处理无论是HeapCreate或GetProcessHeap函数返回。
dwFlags [in]
堆访问选项。此参数可以是以下值。
ValueMeaning
HEAP_NO_SERIALIZE
0x00000001Serialized访问将不会被使用。有关更多信息,请参见备注。
为了确保序列化的访问被禁用所有这个函数调用,指定在调用HEAP_NO_SERIALIZE的HeapCreate。在这种情况下,没有必要的补充规定,在此函数调用HEAP_NO_SERIALIZE。
不指定此值时访问进程堆。该系统可在应用中创建的过程中,如按Ctrl + C处理,即同时访问进程堆额外的线程。
返回值
如果函数成功,返回值是最大的承诺空闲块的堆以字节大小。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
在不太可能的情况下,根本没有空间可在堆中,函数的返回值是零,GetLastError返回值NO_ERROR。
备注
该HeapCompact功能主要是对调试有用。通常,系统契约每当HeapFree函数被调用堆,和HeapCompact函数返回最大的堆块大小自由,但不压缩堆下去。如果对自由的全局标志禁用堆凝聚是调试过程中设置的系统不紧凑堆并呼吁HeapCompact函数不紧凑堆。更多关于全球标志信息,请参阅GFlags的文档。
也不能保证一个应用程序可以成功地分配了由HeapCompact返回内存块的大小。其他线程或犯下的门槛可能会阻止这种分配。
序列化,确保相互排斥的两个或多个线程试图同时分配或来自同一堆空闲块。有一个小的性能成本的序列化,但必须使用多线程分配时,从同一个堆的可用内存。设置HEAP_NO_SERIALIZE价值消除了堆相互排斥。没有系列化,两个或多个线程使用同一个堆句柄可能试图分配或释放内存同时,在堆可能滋生腐败。该HEAP_NO_SERIALIZE值,因此,可以放心使用只有在下列情况下:
这个过程只有一个线程。
这一进程的多个线程,但只有一个线程调用特定堆的堆函数。
这一进程的多个线程,并且应用程序提供了相互排斥的机制,以一个特定的堆。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
堆函数
HeapCreate
HeapValidate
内存管理功能
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==HeapCompact Function
Returns the size of the largest committed free block in the specified heap. If the Disable heap coalesce on free global flag is set, this function also coalesces adjacent free blocks of memory in the heap.
Syntax
C++
SIZE_T WINAPI HeapCompact(
__in HANDLE hHeap,
__in DWORD dwFlags
);
Parameters
hHeap [in]
A handle to the heap. This handle is returned by either the HeapCreate or GetProcessHeap function.
dwFlags [in]
The heap access options. This parameter can be the following value.
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.

Return Value
If the function succeeds, the return value is the size of the largest committed free block in the heap, in bytes.
If the function fails, the return value is zero. To get extended error information, call GetLastError .
In the unlikely case that there is absolutely no space available in the heap, the function return value is zero, and GetLastError returns the value NO_ERROR.
Remarks
The HeapCompact function is primarily useful for debugging. Ordinarily, the system compacts the heap whenever the HeapFree function is called, and the HeapCompact function returns the size of the largest free block in the heap but does not compact the heap any further. If the Disable heap coalesce on free global flag is set during debugging, the system does not compact the heap and calling the HeapCompact function does compact the heap. For more information about global flags, see the GFlags documentation.
There is no guarantee that an application can successfully allocate a memory block of the size returned by HeapCompact. Other threads or the commit threshold might prevent such an allocation.
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.
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
Heap Functions
HeapCreate
HeapValidate
Memory Management Functions
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa366598(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:20:27