Skip to content

Modern Fs MemoryMappedFile Close

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Filesystem › Filesystem Library › MemoryMappedFile.Close

MemoryMappedFile.Close

Unmaps the file; harmless when nothing is mapped.

Syntax

MemoryMappedFile.Close( )

Examples

#import "std/fs"
using fs

dim td as FsResultUStr = CreateTempDir( "fbdoc" )
dim as ustring dir_ = td.Value( )
dim as ustring p = PathJoin( dir_, "f.txt" )
WriteAllText( p, "hello" )

dim mm as MemoryMappedFile
mm.Open( p )
mm.Close( )

print mm.IsOpen( )           '' false

'' Closing twice is harmless, and the DESTRUCTOR closes too -- so a
'' mapping that goes out of scope does not leak the handle
mm.Close( )
print mm.IsOpen( )           '' false

RemoveDirAll( dir_ )

Library: Filesystem Library
Category: Filesystem
Documented under: Locking, Mapping And Watching

Clone this wiki locally