Skip to content

Latest commit

 

History

History
116 lines (78 loc) · 3.42 KB

nf-memoryapi-discardvirtualmemory.md

File metadata and controls

116 lines (78 loc) · 3.42 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:memoryapi.DiscardVirtualMemory
DiscardVirtualMemory function (memoryapi.h)
Discards the memory contents of a range of memory pages, without decommitting the memory. The contents of discarded memory is undefined and must be rewritten by the application.
DiscardVirtualMemory
DiscardVirtualMemory function
base.discardvirtualmemory
winbase/DiscardVirtualMemory
base\discardvirtualmemory.htm
base
942e80cb-5a68-24fa-5d5d-fe3741bee2dc
12/05/2018
DiscardVirtualMemory, DiscardVirtualMemory function, base.discardvirtualmemory, winbase/DiscardVirtualMemory
memoryapi.h
Windows.h, Memoryapi.h
Windows
Windows 8.1 Update [desktop apps \| UWP apps]
Windows Server 2012 R2 Update [desktop apps \| UWP apps]
onecore.lib
Kernel32.dll
Windows
19H1
DiscardVirtualMemory
memoryapi/DiscardVirtualMemory
c++
APIRef
kbSyntax
DllExport
Kernel32.dll
API-MS-Win-Core-memory-l1-1-2.dll
KernelBase.dll
API-MS-Win-Core-memory-l1-1-3.dll
MinKernelBase.dll
API-MS-Win-Core-Memory-L1-1-4.dll
DiscardVirtualMemory

DiscardVirtualMemory function

-description

Discards the memory contents of a range of memory pages, without decommitting the memory. The contents of discarded memory is undefined and must be rewritten by the application.

-parameters

-param VirtualAddress [in]

Page-aligned starting address of the memory to discard.

-param Size [in]

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

-returns

ERROR_SUCCESS if successful; a System Error Code otherwise.

-remarks

If DiscardVirtualMemory fails, the contents of the region is not altered.

Use this function to discard memory contents that are no longer needed, while keeping the memory region itself committed. Discarding memory may give physical RAM back to the system. When the region of memory is again accessed by the application, the backing RAM is restored, and the contents of the memory is undefined.

Important  Calls to DiscardVirtualMemory will fail if the memory protection is not PAGE_READWRITE.
 

-see-also

Memory Management Functions

OfferVirtualMemory

ReclaimVirtualMemory

Virtual Memory Functions

VirtualAlloc

VirtualFree

VirtualLock

VirtualQuery