UnmapViewOfFile
The UnmapViewOfFile function unmaps a previously mapped view of a file from the caller's virtual address space.
Syntax
BOOL UnmapViewOfFile(
_In_ PVOID BaseAddress
);
Parameters
| Parameter | Description |
|---|---|
BaseAddress |
A pointer to the base address of the memory range to be unmapped. This address should be a base address returned by a previous call to MapViewOfFile, MapViewOfFileEx, or MapViewOfFileNuma.
|
Return value
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE. To get extended error information, call GetLastError.
Remarks
Calling UnmapViewOfFile frees the virtual address space that was previously committed for the specified file mapping. The underlying physical pages are not affected until the file mapping object itself is deleted by closing its handle.
If you have mapped a view of a file multiple times using MapViewOfFile, MapViewOfFileEx, or MapViewOfFileNuma, you must call UnmapViewOfFile once for each successful call to these mapping functions.
It is an error to unmap a view of a file that has been modified and not yet written to disk. Ensure all changes are flushed to the file before unmapping the view, or use FlushViewOfFile if necessary.
Requirements
| Attribute | Value |
|---|---|
| Minimum supported client | Windows XP [desktop apps | UWP apps] |
| Minimum supported server | Windows Server 2003 [desktop apps | UWP apps] |
| Header | memoryapi.h |
| Library | Kernel32.lib |
| DLL | Kernel32.dll |