Home

UnmapViewOfFile

UnmapViewOfFile is a Windows API function in Kernel32.dll that unmaps a mapped view of a file from the calling process’s address space. It is used after a program has mapped a file into memory using MapViewOfFile, MapViewOfFileEx, or related functions such as MapViewOfFile3. The function signature is BOOL UnmapViewOfFile(LPCVOID lpBaseAddress), where lpBaseAddress is the base address of the mapped view returned by the mapping call.

On success, UnmapViewOfFile returns a nonzero value. On failure, it returns zero and extended error information

Common error conditions include passing a pointer that does not refer to a mapped view in the

See also MapViewOfFile, MapViewOfFileEx, MapViewOfFile3, CreateFileMapping, OpenFileMapping.

is
available
via
GetLastError.
The
operation
affects
only
the
calling
process:
unmapping
a
view
in
one
process
does
not
unmap
views
in
other
processes,
even
if
those
processes
map
the
same
file.
Unmapping
decreases
the
per-process
reference
for
that
view;
if
no
views
remain
in
the
process,
the
corresponding
resources
may
be
freed.
UnmapViewOfFile
does
not
close
the
file-mapping
object
itself;
the
object
may
still
exist
if
other
mappings
or
handles
remain.
calling
process’s
address
space,
in
which
case
GetLastError
may
return
ERROR_INVALID_ADDRESS.
The
function
is
a
low-level
operation
that
interacts
with
the
system’s
memory
manager
and
is
typically
used
to
ensure
proper
release
of
resources
when
a
memory-mapped
file
is
no
longer
needed.