网站首页  词典首页

请输入您要查询的函数:

 

术语 heapcreate
释义 HeapCreate
语法:
C++
HANDLE WINAPI HeapCreate(
__in DWORD flOptions,
__in SIZE_T dwInitialSize,
__in SIZE_T dwMaximumSize
);
HeapCreate功能
创建一个堆对象,私人可以通过调用进程使用。该功能保护区面积在进程的虚拟地址空间,并分配一个指定的此块的初始部分物理存储。
参数
flOptions [in]
堆分配方案。通过这些选项会影响到堆函数调用后进入新的堆积。此参数可以是0或一个或多个下列值。
ValueMeaning
HEAP_CREATE_ENABLE_EXECUTE
0x00040000All内存块的分配从这个堆允许执行代码,如果硬件强制执行数据执行预防。在应用程序中使用此标志堆,从堆运行代码。如果HEAP_CREATE_ENABLE_EXECUTE没有指定的应用程序尝试从受保护的运行页面代码,应用程序接收与状态代码STATUS_ACCESS_VIOLATION例外。
HEAP_GENERATE_EXCEPTIONS
0x00000004The系统引发异常以指示失败(例如,一个地地道道的内存不足的情况,而不是返回NULL呼吁HeapAlloc和HeapReAlloc)。
HEAP_NO_SERIALIZE
0x00000001Serialized访问时,不使用的堆函数访问此堆。此选项适用于所有后续堆函数调用。或者,您可以指定此个别堆函数调用的选项。
低碎片堆(LFH)不能启用此选项创建一个堆。
此选项创建的堆无法锁定。
如需有关串行访问信息,请参阅本主题的备注部分。
dwInitialSize [in]
堆的初始大小,以字节为单位。此值决定了内存的初始量为堆承诺。该值舍入到一个系统页大小的倍数。该值必须小于dwMaximumSize。
如果此参数为0,函数即一页。要确定在主机上的一个页面的大小,使用的GetSystemInfo函数。
dwMaximumSize [in]
堆的最大大小,以字节为单位。函数的HeapCreate轮dwMaximumSize到一个系统页大小的倍数,然后储备堆的,在进程的虚拟地址空间的大小块。如果被HeapAlloc或HeapReAlloc地分配职能的要求,超过dwInitialSize指定的大小,系统为堆承诺额外的内存页,直至堆的最大大小。
如果dwMaximumSize不为零,堆的大小是固定的,不能生长。 The largest memory block that can be allocated from the heap is slightly less than 0x7FFF8 bytes.请拨块大失败,即使堆的最大大小足够大,以包含块。低碎片堆不能启用一个有固定大小的堆。
如果dwMaximumSize为0,堆可以做强。堆的大小只受限于可用的内存。请拨块大于0x7FFF8字节不自动失败。该系统调用VirtualAlloc函数以获取是需要大的内存块。应用程序需要分配大的内存块应该dwMaximumSize为0。
返回值
如果函数成功,返回值是一个句柄到新创建的堆。
如果函数失败,返回值为NULL。为了获得更多错误信息,调用GetLastError。
备注
该HeapCreate函数创建一个堆对象的私人从中调用进程可以分配使用HeapAlloc函数的内存块。最初的大小决定了该分配的堆最初承诺的页数。最大大小决定保留的页面总数。这些网页创建一个进程的虚拟地址空间到其中的堆成长块。如果HeapAlloc要求超出目前的规模犯页,其他页会自动从这个承诺预留的空间,如果物理存储空间。
Windows Server 2003中,Windows XP和Windows 2000 SP4的和修复KB 816542:默认情况下,新创建的私有堆是一个标准堆。为了使低碎片堆,调用句柄私人堆HeapSetInformation功能。
一个私人堆对象的内存只能访问创建它的进程。如果一个动态链接库(DLL)创建一个私有堆,堆中创建的进程调用的DLL的地址空间,它只能访问该进程。
该系统使用私人堆内存堆支持存储结构,所以没有指定堆大小都可以对这一进程。例如,如果HeapAlloc功能的要求,从64千字节的最大大小为64K堆(金),请求可能失败,因为系统的开销。
如果没有指定HEAP_NO_SERIALIZE(简单默认),堆在调用序列化进程访问。序列化,确保相互排斥的两个或多个线程试图同时分配或来自同一堆空闲块。有一个小的性能成本的序列化,但必须使用多线程分配时,从同一个堆的可用内存。在HeapLock和HeapUnlock功能可用于阻止和允许访问序列化堆。
设置HEAP_NO_SERIALIZE消除了堆相互排斥。没有系列化,两个或多个线程使用同一个堆句柄可能试图分配或释放内存同时,这可能导致堆损坏。因此,HEAP_NO_SERIALIZE可以安全地只能用于在下列情况下:
这个过程只有一个线程。
这一进程的多个线程,但只有一个线程调用特定堆的堆函数。
这一进程的多个线程,并且应用程序提供了相互排斥的机制,以一个特定的堆。
如果HeapLock和HeapUnlock功能上与HEAP_NO_SERIALIZATION旗创建了一个名为堆,结果是不确定的。
要获取的句柄默认堆的过程,使用GetProcessHeap功能。要获取处理的默认堆和,这对于调用进程活跃的私营堆,使用GetProcessHeaps功能。
实例
他列举了堆
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
堆函数
HeapAlloc
HeapDestroy
HeapValidate
内存管理功能
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==HeapCreate Function
Creates a private heap object that can be used by the calling process. The function reserves space in the virtual address space of the process and allocates physical storage for a specified initial portion of this block.
Syntax
C++
HANDLE WINAPI HeapCreate(
__in DWORD flOptions,
__in SIZE_T dwInitialSize,
__in SIZE_T dwMaximumSize
);
Parameters
flOptions [in]
The heap allocation options. These options affect subsequent access to the new heap through calls to the heap functions. This parameter can be 0 or one or more of the following values.
ValueMeaning
HEAP_CREATE_ENABLE_EXECUTE
0x00040000All memory blocks that are allocated from this heap allow code execution, if the hardware enforces data execution prevention . Use this flag heap in applications that run code from the heap. If HEAP_CREATE_ENABLE_EXECUTE is not specified and an application attempts to run code from a protected page, the application receives an exception with the status code STATUS_ACCESS_VIOLATION.
HEAP_GENERATE_EXCEPTIONS
0x00000004The system raises an exception to indicate failure (for example, an out-of-memory condition) for calls to HeapAlloc and HeapReAlloc instead of returning NULL.
HEAP_NO_SERIALIZE
0x00000001Serialized access is not used when the heap functions access this heap. This option applies to all subsequent heap function calls. Alternatively, you can specify this option on individual heap function calls.
The low-fragmentation heap (LFH) cannot be enabled for a heap created with this option.
A heap created with this option cannot be locked.
For more information about serialized access, see the Remarks section of this topic.

dwInitialSize [in]
The initial size of the heap, in bytes. This value determines the initial amount of memory that is committed for the heap. The value is rounded up to a multiple of the system page size. The value must be smaller than dwMaximumSize.
If this parameter is 0, the function commits one page. To determine the size of a page on the host computer, use the GetSystemInfo function.
dwMaximumSize [in]
The maximum size of the heap, in bytes. The HeapCreate function rounds dwMaximumSize up to a multiple of the system page size and then reserves a block of that size in the process's virtual address space for the heap. If allocation requests made by the HeapAlloc or HeapReAlloc functions exceed the size specified by dwInitialSize, the system commits additional pages of memory for the heap, up to the heap's maximum size.
If dwMaximumSize is not zero, the heap size is fixed and cannot grow. The largest memory block that can be allocated from the heap is slightly less than 0x7FFF8 bytes. Requests to allocate larger blocks fail, even if the maximum size of the heap is large enough to contain the block. The low-fragmentation heap cannot be enabled for a heap with a fixed size.
If dwMaximumSize is 0, the heap can grow in size. The heap's size is limited only by the available memory. Requests to allocate blocks larger than 0x7FFF8 bytes do not automatically fail. The system calls the VirtualAlloc function to obtain the memory that is needed for large blocks. Applications that need to allocate large memory blocks should set dwMaximumSize to 0.
Return Value
If the function succeeds, the return value is a handle to the newly created heap.
If the function fails, the return value is NULL. To get extended error information, call GetLastError .
Remarks
The HeapCreate function creates a private heap object from which the calling process can allocate memory blocks by using the HeapAlloc function. The initial size determines the number of committed pages that are allocated initially for the heap. The maximum size determines the total number of reserved pages. These pages create a block in the process's virtual address space into which the heap can grow. If requests by HeapAlloc exceed the current size of committed pages, additional pages are automatically committed from this reserved space, if the physical storage is available.
Windows Server 2003, Windows XP, and Windows 2000 with SP4 and hotfix KB 816542 : By default, the newly created private heap is a standard heap. To enable the low-fragmentation heap, call the HeapSetInformation function with a handle to the private heap.
The memory of a private heap object is accessible only to the process that created it. If a dynamic-link library (DLL) creates a private heap, the heap is created in the address space of the process that calls the DLL, and it is accessible only to that process.
The system uses memory from the private heap to store heap support structures, so not all of the specified heap size is available to the process. For example, if the HeapAlloc function requests 64 kilobytes (K) from a heap with a maximum size of 64K, the request may fail because of system overhead.
If HEAP_NO_SERIALIZE is not specified (the simple default), the heap serializes access within the calling process. Serialization ensures mutual exclusion when two or more threads attempt simultaneously to 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. The HeapLock and HeapUnlock functions can be used to block and permit access to a serialized heap.
Setting HEAP_NO_SERIALIZE 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, which may cause corruption in the heap. Therefore, HEAP_NO_SERIALIZE can safely be 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.
If the HeapLock and HeapUnlock functions are called on a heap created with the HEAP_NO_SERIALIZATION flag, the results are undefined.
To obtain a handle to the default heap for a process, use the GetProcessHeap function. To obtain handles to the default heap and private heaps that are active for the calling process, use the GetProcessHeaps function.
Examples
Enumerating a 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
HeapDestroy
HeapValidate
Memory Management Functions
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa366599(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:23:43