MATLAB Function Reference | ![]() ![]() |
Syntax
pack pack filename pack('filename')
Description
pack
frees up needed space by compressing information into the minimum memory required. You must run pack
from a directory for which you have write permission.
pack filename
accepts an optional filename
for the temporary file used to hold the variables. Otherwise, it uses the file named pack.tmp
. You must run pack
from a directory for which you have write permission.
pack('filename')
is the function form of pack
.
Remarks
The pack
function does not affect the amount of memory allocated to the MATLAB process. You must quit MATLAB to free up this memory.
Since MATLAB uses a heap method of memory management, extended MATLAB sessions may cause memory to become fragmented. When memory is fragmented, there may be plenty of free space, but not enough contiguous memory to store a new large variable.
If you get the Out
of
memory
message from MATLAB, the pack
function may find you some free memory without forcing you to delete variables.
The pack
function frees space by:
pack.tmp
pack.tmp
pack.tmp
If you use pack
and there is still not enough free memory to proceed, you must clear some variables. If you run out of memory often, you can allocate larger matrices earlier in the MATLAB session and use these system-specific tips:
Examples
Change the current directory to one that is writable, run pack
, and return to the previous directory.
cwd = pwd; cd(tempdir); pack cd(cwd)
See Also
![]() | otherwise | pagedlg | ![]() |