pack
(To be removed) Consolidate workspace memory
pack
will be removed in a future release. There is no replacement for
this function. For more information, see Compatibility Considerations.
Syntax
Description
pack
reorganizes workspace data to maximize the size of the largest
contiguous free memory block. It consolidates fragmented memory by:
Saving all variables in the base and function workspaces to a temporary file
Clearing all variables and functions from memory
Reloading the base and function workspace variables back from the temporary file and then deleting the file
Note
When MATLAB® runs out of memory on a 32-bit system, pack
might
find you some free memory without forcing you to delete variables. On a 64-bit system,
you do not need to use pack
. For more information about strategies
for reducing memory usage, see Strategies for Efficient Use of Memory
and Resolve “Out of Memory” Errors.
pack
frees space in memory,
temporarily storing workspace data in a file specified by
filename
filename
.
Examples
Input Arguments
Limitations
The
pack
function is supported only in the Command Window. You cannot call it from a function or script.If the workspace contains a variable larger than 2 GB,
pack
cannot save and reload your data.The
pack
function does not affect the amount of memory allocated to the MATLAB process. You must end your MATLAB session to free up this memory.
Tips
The
pack
function initializes all persistent variables to an empty matrix ([]
). To maintain the value of persistent variables when you runpack
, usemlock
in the functions in which they are declared.Do not use the
pack
function with objects that define events and listeners.pack
causes the destruction of any listeners defined for the objects in the workspace. For information about restoring listeners when saving objects, see Restore Listeners.