Kernel32HeapCreate Method
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.
Namespace: DevCase.Win32.NativeMethodsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("Kernel32.dll", SetLastError = true)]
public static IntPtr HeapCreate(
HeapFlags options,
uint initialSize,
uint maximumSize
)
<DllImportAttribute("Kernel32.dll", SetLastError := true>]
Public Shared Function HeapCreate (
options As HeapFlags,
initialSize As UInteger,
maximumSize As UInteger
) As IntPtr
Dim options As HeapFlags
Dim initialSize As UInteger
Dim maximumSize As UInteger
Dim returnValue As IntPtr
returnValue = Kernel32.HeapCreate(options,
initialSize, maximumSize)
public:
[DllImportAttribute(L"Kernel32.dll", SetLastError = true)]
static IntPtr HeapCreate(
HeapFlags options,
unsigned int initialSize,
unsigned int maximumSize
)
[<DllImportAttribute("Kernel32.dll", SetLastError = true)>]
static member HeapCreate :
options : HeapFlags *
initialSize : uint32 *
maximumSize : uint32 -> IntPtr
No code example is currently available or this language may not be supported.
- options HeapFlags
-
The heap allocation options.
These options affect subsequent access to the new heap through calls to the heap functions.
- initialSize UInt32
-
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 maximumSize.
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.
- maximumSize UInt32
-
The maximum size of the heap, in bytes.
The HeapCreate(HeapFlags, UInt32, UInt32) function rounds maximumSize 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(IntPtr, HeapFlags, UInt32) or
HeapReAlloc(IntPtr, HeapFlags, IntPtr, UInt32) functions exceed the size specified by initialSize,
the system commits additional pages of memory for the heap, up to the heap's maximum size.
If maximumSize is not zero, the heap size is fixed and cannot grow beyond the maximum size.
Also, the largest memory block that can be allocated from the heap is slightly less than 512 KB for a 32-bit process
and slightly less than 1,024 KB for a 64-bit process.
Requests to allocate larger blocks fail, even if the maximum size of the heap is large enough to contain the block.
If maximumSize is 0, the heap can grow in size.
The heap's size is limited only by the available memory.
Requests to allocate memory blocks larger than the limit for a fixed-size heap do not automatically fail;
instead, the system calls the VirtualAlloc(IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) function
to obtain the memory that is needed for large blocks.
Applications that need to allocate large memory blocks should set maximumSize to 0.
IntPtr
If the function succeeds, the return value is a handle to the newly created heap.
If the function fails, the return value is
Zero.