Delete Memory Map
Ways to Delete a Memory Map
To clear a memmapfile object from memory,
do any of the following:
Reassign another value to the
memmapfileobject's variableClear the
memmapfileobject's variable from memoryExit the function scope in which the
memmapfileobject was created
The Effect of Shared Data Copies On Performance
When you assign the Data field of the memmapfile object
to a variable, MATLAB® makes a shared data copy of the mapped
data. This is very efficient because no memory actually gets copied.
In the following statement, d is a shared data
copy of the data mapped from the file:
d = m.Data;
When you finish using the mapped data, make sure to clear any
variables that share data with the mapped file before clearing the memmapfile object
itself. If you clear the object first, then the sharing of data between
the file and dependent variables is broken, and the data assigned
to such variables must be copied into memory before the object is
cleared. If access to the mapped file was over a network, then copying
this data to local memory can take considerable time. Therefore, if
you assign m.Data to the variable, d,
you should be sure to clear d before clearing m when
you are finished with the memory map.