MemoryAllocationType Enumeration

Specifies the type of memory allocation operation.

Definition

Namespace: DevCase.Win32.Enums
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[FlagsAttribute]
public enum MemoryAllocationType

Remarks

Members

Default 0 This meaning of this value depends on the function on which it is used.
Commit 4,096 Allocates memory charges (from the overall size of memory and the paging files on disk) for the specified reserved memory pages.

The function also guarantees that when the caller later initially accesses the memory, the contents will be zero.

Actual physical pages are not allocated unless/until the virtual addresses are actually accessed.

To reserve and commit pages in one step, call VirtualAllocEx(IntPtr, IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) with Commit and Reserve.

Attempting to commit a specific address range by specifying Commit without Reserve and a non-Zeroaddress fails unless the entire range has already been reserved. The resulting error code is ERROR_INVALID_ADDRESS.

An attempt to commit a page that is already committed does not cause the function to fail. This means that you can commit pages without first determining the current commitment state of each page.

If address specifies an address within an enclave, allocationType must be Commit.

Reserve 8,192 Reserves a range of the process's virtual address space without allocating any actual physical storage in memory or in the paging file on disk.

You commit reserved pages by calling VirtualAllocEx(IntPtr, IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) again with Commit.

To reserve and commit pages in one step, call VirtualAllocEx(IntPtr, IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) with Commit and Reserve.

Other memory allocation functions, such as malloc and LocalAlloc, cannot use reserved memory until it has been released.

Reset 524,288 When calling the VirtualAllocEx(IntPtr, IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) function, indicates that data in the memory range specified by address and size parameters is no longer of interest.

The pages should not be read from or written to the paging file. However, the memory block will be used again later, so it should not be decommitted.

This value cannot be used with any other value.

Using this value does not guarantee that the range operated on with Reset will contain zeros.

If you want the range to contain zeros, decommit the memory and then recommit it.

When you use Reset, the VirtualAllocEx(IntPtr, IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) function ignores the value of protection parameter. However, you must still set fProtect to a valid protection value, such as NoAccess.

VirtualAllocEx(IntPtr, IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) function returns an error if you use Reset and the range of memory is mapped to a file.

A shared view is only acceptable if it is mapped to a paging file.

TopDown 1,048,576 Allocates memory at the highest possible address.

This can be slower than regular allocations, especially when there are many allocations.

Physical 4,194,304 Reserves an address range that can be used to map Address Windowing Extensions (AWE) pages.

This value must be used with Reserve and no other values.

ResetUndo 16,777,216 ResetUndo should only be called on an address range to which Reset was successfully applied earlier.

When calling the VirtualAllocEx(IntPtr, IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) function, it indicates that the data in the specified memory range specified by address and size parameters is of interest to the caller and attempts to reverse the effects of Reset.

If the function succeeds, that means all data in the specified address range is intact.

If the function fails, at least some of the data in the address range has been replaced with zeroes.

This value cannot be used with any other value.

If ResetUndo is called on an address range which was not Reset earlier, the behavior is undefined.

When you specify Reset, the VirtualAllocEx(IntPtr, IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) function ignores the value of protection parameter. However, you must still set protection parameter to a valid protection value, such as NoAccess.

LargePages 536,870,912 Allocates memory using large page support.

The size and alignment must be a multiple of the large-page minimum.

To obtain this value, use the GetLargePageMinimum function.

See Also