Export (0) Print
Expand All
Expand Minimize

Memory Management Functions

This topic describes the memory management functions:

General Memory Functions

The following functions are used in memory management.

FunctionDescription
AddSecureMemoryCacheCallback Registers a callback function to be called when a secured memory range is freed or its protections are changed.
CopyMemory Copies a block of memory from one location to another.
CreateMemoryResourceNotification Creates a memory resource notification object.
FillMemory Fills a block of memory with a specified value.
GetLargePageMinimum Retrieves the minimum size of a large page.
GetPhysicallyInstalledSystemMemory Retrieves the amount of RAM that is physically installed on the computer.
GetSystemFileCacheSize Retrieves the current size limits for the working set of the system cache.
GetWriteWatch Retrieves the addresses of the pages that have been written to in a region of virtual memory.
GlobalMemoryStatusEx Obtains information about the system's current usage of both physical and virtual memory.
MoveMemory Moves a block of memory from one location to another.
QueryMemoryResourceNotification Retrieves the state of the specified memory resource object.
RemoveSecureMemoryCacheCallback Unregisters a callback function that was previously registered with the AddSecureMemoryCacheCallback function.
ResetWriteWatch Resets the write-tracking state for a region of virtual memory.
SecureMemoryCacheCallback An application-defined function that is called when a secured memory range is freed or its protections are changed.
SecureZeroMemory Fills a block of memory with zeros.
SetSystemFileCacheSize Limits the size of the working set for the file system cache.
ZeroMemory Fills a block of memory with zeros.

 

Data Execution Prevention Functions

The following functions are used with Data Execution Prevention (DEP).

FunctionDescription
GetProcessDEPPolicy Retrieves DEP settings for a process.
GetSystemDEPPolicy Retrieves DEP settings for the system.
SetProcessDEPPolicy Changes DEP settings for a process.

 

File Mapping Functions

The following functions are used in file mapping.

FunctionDescription
CreateFileMapping Creates or opens a named or unnamed file mapping object for a specified file.
CreateFileMappingFromApp Creates or opens a named or unnamed file mapping object for a specified file from a Windows Store app.
CreateFileMappingNuma Creates or opens a named or unnamed file mapping object for a specified file, and specifies the NUMA node for the physical memory.
FlushViewOfFile Writes to the disk a byte range within a mapped view of a file.
GetMappedFileName Checks whether the specified address is within a memory-mapped file in the address space of the specified process. If so, the function returns the name of the memory-mapped file.
MapViewOfFile Maps a view of a file mapping into the address space of a calling process.
MapViewOfFileEx Maps a view of a file mapping into the address space of a calling process. A caller can optionally specify a suggested memory address for the view.
MapViewOfFileExNuma Maps a view of a file mapping into the address space of a calling process, and specifies the NUMA node for the physical memory.
MapViewOfFileFromApp Maps a view of a file mapping into the address space of a calling process from a Windows Store app.
OpenFileMapping Opens a named file mapping object.
UnmapViewOfFile Unmaps a mapped view of a file from the calling process's address space.

 

AWE Functions

The following are the AWE functions.

FunctionDescription
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.

 

Heap Functions

The following are the heap functions.

FunctionDescription
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 Coalesces adjacent free blocks of memory on a 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.
HeapQueryInformation Retrieves information about the specified heap.
HeapReAlloc Reallocates a block of memory from a heap.
HeapSetInformation Sets heap information for the specified heap.
HeapSize Retrieves 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.

 

Virtual Memory Functions

The following are the virtual memory functions.

FunctionDescription
PrefetchVirtualMemory Prefetches virtual address ranges into physical memory.
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 specified process.
VirtualAllocExNuma Reserves or commits a region of memory within the virtual address space of the specified process, and specifies the NUMA node for the physical memory.
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.

 

Global and Local Functions

The following are the global and local functions. These functions are provided for compatibility with 16-bit Windows and are used with Dynamic Data Exchange (DDE), the clipboard functions, and OLE data objects. Unless documentation specifically states that a global or local function should be used, new applications should use the corresponding heap function with the handle returned by GetProcessHeap. For equivalent functionality to the global or local function, set the heap function's dwFlags parameter to 0.

FunctionDescriptionCorresponding heap function
GlobalAlloc, LocalAlloc Allocates the specified number of bytes from the heap. HeapAlloc
GlobalDiscard, LocalDiscard Discards the specified global memory block.Not applicable.
GlobalFlags, LocalFlags Returns information about the specified global memory object.Not applicable. Use HeapValidate to validate the heap.
GlobalFree, LocalFree Frees the specified global memory object. HeapFree
GlobalHandle, LocalHandle Retrieves the handle associated with the specified pointer to a global memory block. This function should be used only with OLE and clipboard functions that require it.Not applicable.
GlobalLock, LocalLock Locks a global memory object and returns a pointer to the first byte of the object's memory block.Not applicable.
GlobalReAlloc, LocalReAlloc Changes the size or attributes of a specified global memory object. HeapReAlloc
GlobalSize, LocalSize Retrieves the current size of the specified global memory object. HeapSize
GlobalUnlock, LocalUnlock Decrements the lock count associated with a memory object. This function should be used only with OLE and clipboard functions that require it.Not applicable.

 

Bad Memory Functions

The following are the bad memory functions.

FunctionDescription
BadMemoryCallbackRoutine An application-defined function registered with the RegisterBadMemoryNotification function that is called when one or more bad memory pages are detected.
GetMemoryErrorHandlingCapabilities Gets the memory error handling capabilities of the system.
RegisterBadMemoryNotification Registers a bad memory notification that is called when one or more bad memory pages are detected.
UnregisterBadMemoryNotification Closes the specified bad memory notification handle.

 

Obsolete Functions

The following functions are provided only for compatibility with 16-bit versions of Windows:

The following function can return incorrect information and should not be used. Use the GlobalMemoryStatusEx function instead:

 

 

Community Additions

ADD
Show:
© 2014 Microsoft