Kernel32VirtualFree(UIntPtr, UIntPtr, MemoryFreeType) Method
Releases, decommits, or releases and decommits a region of pages
within the virtual address space of the calling process.
To free memory allocated in another process by the
VirtualAllocEx(IntPtr, IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) function,
use the
VirtualFreeEx(IntPtr, IntPtr, IntPtr, MemoryFreeType) function.
Namespace: DevCase.Win32.NativeMethodsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("Kernel32.dll", SetLastError = true)]
public static bool VirtualFree(
UIntPtr address,
UIntPtr size,
MemoryFreeType freeType
)
<DllImportAttribute("Kernel32.dll", SetLastError := true>]
Public Shared Function VirtualFree (
address As UIntPtr,
size As UIntPtr,
freeType As MemoryFreeType
) As Boolean
Dim address As UIntPtr
Dim size As UIntPtr
Dim freeType As MemoryFreeType
Dim returnValue As Boolean
returnValue = Kernel32.VirtualFree(address,
size, freeType)
public:
[DllImportAttribute(L"Kernel32.dll", SetLastError = true)]
static bool VirtualFree(
[InAttribute] UIntPtr address,
UIntPtr size,
MemoryFreeType freeType
)
[<DllImportAttribute("Kernel32.dll", SetLastError = true)>]
static member VirtualFree :
address : UIntPtr *
size : UIntPtr *
freeType : MemoryFreeType -> bool
No code example is currently available or this language may not be supported.
- address UIntPtr
-
A pointer to the base address of the region of pages to be freed.
If the freeType parameter is Release,
this parameter must be the base address returned by the VirtualAlloc(IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) function
when the region of pages is reserved.
- size UIntPtr
-
The size of the region of memory to be freed, in bytes.
If the freeType parameter is Release,
this parameter must be 0 (zero).
The function frees the entire region that is reserved
in the initial allocation call to VirtualAlloc(IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) function.
If the dwFreeType parameter is Decommit,
the function decommits all memory pages that contain one or more bytes
in the range from the address parameter to (address+size).
This means, for example, that a 2-byte region of memory that straddles a page boundary
causes both pages to be decommitted.
If address parameter is the base address returned by
VirtualAlloc(IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions) and size parameter is 0 (zero),
the function decommits the entire region that is allocated by VirtualAlloc(IntPtr, IntPtr, MemoryAllocationType, MemoryProtectionOptions).
After that, the entire region is in the reserved state.
- freeType MemoryFreeType
-
The type of free operation.
Boolean
If the function succeeds, the return value is
.
If the function fails, the return value is
.
To get extended error information, call
GetLastWin32Error.