Create memory map to a file
maps
an existing file, m
= memmapfile(filename
)filename
, to memory and returns
the memory map, m
.
Memory-mapping is a mechanism that maps a portion of a file, or an entire file, on disk to a range of memory addresses within the MATLAB® address space. Then, MATLAB can access files on disk in the same way it accesses dynamic memory, accelerating file reading and writing. Memory-mapping allows you to work with data in a file as if it were a MATLAB array.
specifies
the properties of m
= memmapfile(filename
,Name,Value
)m
using one or more name-value
pair arguments. For example, you can specify the format of the data
in the file.
You can map only an existing file. You cannot create a new file and map that file to memory in one operation. Use the MATLAB file I/O functions to create the file before attempting to map it to memory.
After memmapfile
locates the
file, MATLAB stores the file’s absolute pathname internally,
and then uses this stored path to locate the file from that point
on. As a result, you can work in other directories outside your current
work directory and retain access to the mapped file.
memmapfile
does not expand or
append to a mapped file. Use instead standard file I/O functions like fopen
and fwrite
.
The actual mapping of a file to the MATLAB address space
does not take place when you construct a memmapfile
object.
A memory map, based on the information currently stored in the mapped
object, is generated the first time you reference or modify the Data
property
for that object.