ReclaimVirtualMemory function (memoryapi.h)

Reclaims a range of memory pages that were offered to the system with OfferVirtualMemory.

If the offered memory has been discarded, the contents of the memory region is undefined and must be rewritten by the application. If the offered memory has not been discarded, it is reclaimed intact.

Syntax

DWORD ReclaimVirtualMemory(
  [in] void const *VirtualAddress,
  [in] SIZE_T     Size
);

Parameters

[in] VirtualAddress

Page-aligned starting address of the memory to reclaim.

[in] Size

Size, in bytes, of the memory region to reclaim. Size must be an integer multiple of the system page size.

Return value

Returns ERROR_SUCCESS if successful and the memory was reclaimed intact.

Returns ERROR_BUSY if successful but the memory was discarded and must be rewritten by the application. In this case, the contents of the memory region is undefined.

Returns a System Error Code otherwise.

Remarks

Reclaimed memory pages can be used by the application, and will be written to the system paging file if paging occurs.

If the function returns ERROR_SUCCESS, the data in the reclaimed pages is valid. If the function returns ERROR_BUSY, the data in the reclaimed pages was discarded by the system and is no longer valid. For this reason, memory should only be offered to the system if the application does not need or can regenerate the data.

Requirements

Requirement Value
Minimum supported client Windows 8.1 Update [desktop apps | UWP apps]
Minimum supported server Windows Server 2012 R2 Update [desktop apps | UWP apps]
Target Platform Windows
Header memoryapi.h (include Windows.h, Memoryapi.h)
Library onecore.lib
DLL Kernel32.dll

See also

Memory Management Functions

OfferVirtualMemory

Virtual Memory Functions

VirtualAlloc

VirtualFree

VirtualLock

VirtualQuery