[This is preliminary documentation and subject to change.]
The VirtualFreeVlm function decommits a memory region within the VLM address space of the specified process.
BOOL VirtualFreeVlm(
HANDLE hProcess, // process within which to free memory
PVOID64 lpAddress, // address of region of pages to free
DWORDLONG ullSize, // size in bytes of region
DWORD dwFreeType // type of free operation
);
The release can be done only on the whole virtual space region reserved, whereas decommitting can be performed on subareas of a reserved and committed region. Decommitting an uncommitted area has no effect.
Value | Meaning |
---|---|
MEM_DECOMMIT | Releases the specified region of pages. The pages enter the free state. If you specify this flag and ullSize contains zero, the entire region of pages is decommitted. Otherwise, you must specify lpAddress and ullSize values that are within the range returned by VirtualAllocVlm when the region was reserved. Note that MEM_DECOMMIT only results in the releasing of pages — the virtual address space remains reserved and cannot be reused unless a MEM_RELEASE flag is passed. For more information on reservation of virtual address space, see the discussion of the MEM_RESERVE flag in the VirtualAllocMem topic. |
An attempt to decommit an uncommitted page does not cause VirtualFreeVlm to fail. Thus, a range of committed or uncommitted pages can be decommitted without causing a failure. | |
MEM_RELEASE | Releases the specified region of pages. The pages enter the free state. If you specify this flag, ullSize must be zero and lpAddress must point to the base address returned by VirtualAllocVlm when the region was reserved. VirtualFreeVlm fails if either of these conditions is not met. If VirtualFreeVlm succeeds, both the pages and the range of virtual address space are relinquished. |
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
VirtualFreeVlm decommits memory allocated with VirtualAllocVlm. VirtualFreeVlm can perform one of the following operations:
To release a region of pages, the entire range of pages must be in the same state (all reserved or all committed) and the entire region originally reserved by VirtualAllocVlm must be released at the same time. If only part of the pages in the original reserved region are committed, you must first call VirtualFreeVlm to decommit the committed pages and then call VirtualFreeVlm again to release the entire block.
Pages that have been released are free and available for subsequent allocation operations. Attempting to read from or write to a free page results in an access violation exception.
VirtualFreeVlm can decommit an uncommitted page; this means that a range of committed or uncommitted pages can be decommitted without having to worry about a failure. Decommitting a page releases its physical storage from memory. If a page is decommitted but not released, its state changes to reserved and it can be committed again by a subsequent call to VirtualAllocVlm. Attempting to read from or write to a reserved page results in an access violation exception.
The current state of the entire range of pages to be decommitted must be compatible with the type of free operation specified by the dwFreeType parameter. Otherwise, VirtualFreeVlm fails and no pages are released or decommitted.
Windows NT: Requires version 5.0 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Memory Management Overview, Memory Management Functions, Very Large Memory (VLM), GlobalAlloc, GlobalFree, OpenProcess, VirtualFree, VirtualAllocVlm