网站首页  词典首页

请输入您要查询的函数:

 

术语 heapsize
释义 HeapSize
语法:
C++
SIZE_T WINAPI HeapSize(
__in HANDLE hHeap,
__in DWORD dwFlags,
__in LPCVOID lpMem
);
HeapSize功能
检索内存从法律上的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函数返回一个指针。该内存块必须从由hHeap参数指定的堆。
返回值
如果函数成功,返回值是分配的内存块要求大小,以字节。
如果函数失败,返回值是(SIZE_T)-1。该函数不调用SetLastError。应用程序不能要求扩展的错误信息GetLastError函数。
如果lpMem参数是指堆分配不是由hHeap参数指定的堆,该HeapSize函数的行为是不确定的。
备注
序列化,确保相互排斥的两个或多个线程试图同时分配或来自同一堆空闲块。有一个小的性能成本的序列化,但必须使用多线程分配时,从同一个堆的可用内存。设置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日
==英文原文==HeapSize Function
Retrieves the size of a memory block allocated from a heap by the HeapAlloc or HeapReAlloc function.
Syntax
C++
SIZE_T WINAPI HeapSize(
__in HANDLE hHeap,
__in DWORD dwFlags,
__in LPCVOID lpMem
);
Parameters
hHeap [in]
A handle to the heap in which the memory block resides. This handle is returned by either the HeapCreate or GetProcessHeap function.
dwFlags [in]
The heap size 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.
This value should not be specified 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 whose size the function will obtain. This is a pointer returned by the HeapAlloc or HeapReAlloc function. The memory block must be from the heap specified by the hHeap parameter.
Return Value
If the function succeeds, the return value is the requested size of the allocated memory block, in bytes.
If the function fails, the return value is (SIZE_T) -1. The function does not call SetLastError . An application cannot call GetLastError for extended error information.
If the lpMem parameter refers to a heap allocation that is not in the heap specified by the hHeap parameter, the behavior of the HeapSize function is undefined.
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 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
HeapAlloc
HeapReAlloc
Memory Management Functions
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa366706(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:15:46