Platform SDK: Memory

Memory Management Functions

The following functions are used in memory management.

Function Description
CopyMemory Copies a block of memory from one location to another.
FillMemory Fills a block of memory with a specified value.
GetWriteWatch Retrieves the addresses of the pages that have been written to in a region of virtual memory.
GlobalMemoryStatus Obtains information about the system's current usage of both physical and virtual memory.
GlobalMemoryStatusEx Obtains information about the system's current usage of both physical and virtual memory.
IsBadCodePtr Determines whether the calling process has read access to the memory at the specified address.
IsBadReadPtr Verifies that the calling process has read access to the specified range of memory.
IsBadStringPtr Verifies that the calling process has read access to a range of memory pointed to by a string pointer.
IsBadWritePtr Verifies that the calling process has write access to the specified range of memory.
MoveMemory Moves a block of memory from one location to another.
ResetWriteWatch Resets the write-tracking state for a region of virtual memory.
ZeroMemory Fills a block of memory with zeros.

The following are the AWE functions.

Function Description
AllocateUserPhysicalPages Allocates physical memory pages to be mapped and unmapped within any AWE region of the process.
FreeUserPhysicalPages Frees physical memory pages previously allocated with AllocateUserPhysicalPages.
MapUserPhysicalPages Maps previously allocated physical memory pages at the specified address within an AWE region.
MapUserPhysicalPagesScatter Maps previously allocated physical memory pages at the specified address within an AWE region.

The following are the global and local functions. These functions are slower than other memory management functions and do not provide as many features. Therefore, new applications should use the heap functions. However, the global functions are still used with DDE and the clipboard functions.

Function Description
GlobalAlloc Allocates the specified number of bytes from the heap.
GlobalDiscard Discards the specified global memory block.
GlobalFlags Returns information about the specified global memory object.
GlobalFree Frees the specified global memory object.
GlobalHandle Retrieves the handle associated with the specified pointer to a global memory block.
GlobalLock Locks a global memory object and returns a pointer to the first byte of the object's memory block.
GlobalReAlloc Changes the size or attributes of a specified global memory object.
GlobalSize Retrieves the current size of the specified global memory object.
GlobalUnlock Decrements the lock count associated with a memory object.
LocalAlloc Allocates the specified number of bytes from the heap.
LocalDiscard Discards the specified local memory object.
LocalFlags Returns information about the specified local memory object.
LocalFree Frees the specified local memory object.
LocalHandle Retrieves the handle associated with the specified pointer to a local memory object.
LocalLock Locks a local memory object and returns a pointer to the first byte of the object's memory block.
LocalReAlloc Changes the size or the attributes of a specified local memory object.
LocalSize Returns the current size of the specified local memory object.
LocalUnlock Decrements the lock count associated with a memory object.

The following are the heap functions.

Function Description
GetProcessHeap Obtains a handle to the heap of the calling process.
GetProcessHeaps Obtains handles to all of the heaps that are valid for the calling process.
HeapAlloc Allocates a block of memory from a heap.
HeapCompact Attempts to compact a specified heap.
HeapCreate Creates a heap object.
HeapDestroy Destroys the specified heap object.
HeapFree Frees a memory block allocated from a heap.
HeapLock Attempts to acquire the lock associated with a specified heap.
HeapReAlloc Reallocates a block of memory from a heap.
HeapSize Returns the size of a memory block allocated from a heap.
HeapUnlock Releases ownership of the lock associated with a specified heap.
HeapValidate Attempts to validate a specified heap.
HeapWalk Enumerates the memory blocks in a specified heap.

The following are the virtual memory functions.

Function Description
VirtualAlloc Reserves or commits a region of pages in the virtual address space of the calling process.
VirtualAllocEx Reserves or commits a region of pages in the virtual address space of the calling process.
VirtualFree Releases or decommits a region of pages within the virtual address space of the calling process.
VirtualFreeEx Releases or decommits a region of memory within the virtual address space of a specified process.
VirtualLock Locks the specified region of the process's virtual address space into physical memory.
VirtualProtect Changes the access protection on a region of committed pages in the virtual address space of the calling process.
VirtualProtectEx Changes the access protection on a region of committed pages in the virtual address space of the calling process.
VirtualQuery Provides information about a range of pages in the virtual address space of the calling process.
VirtualQueryEx Provides information about a range of pages in the virtual address space of the calling process.
VirtualUnlock Unlocks a specified range of pages in the virtual address space of a process.

Obsolete Functions

These functions are provided only for compatibility with 16-bit versions of Windows.

DefineHandleTable
GetFreeSpace
GlobalCompact
GlobalFix
GlobalLRUNewest
GlobalLRUOldest
GlobalUnfix
GlobalUnWire
GlobalWire
IsBadHugeReadPtr
IsBadHugeWritePtr
LimitEmsPages
LocalCompact
LocalShrink
LockSegment
SetSwapAreaSize
UnlockSegment