# pack

## Purpose

Consolidate workspace memory.

## Synopsis

    pack
    pack filename

## Description

If you get the `Out` `of` `memory` message from MATLAB, the `pack` command may find you some free memory without forcing you to delete variables.

`pack` frees up needed space by compressing information into the minimum memory required. 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.

The `pack` command

- Saves all variables on disk in a temporary file called `pack.tmp`.
- Clears all variables and functions from memory.
- Reloads the variables back from `pack.tmp`.
- Deletes the temporary file `pack.tmp`.
  This results in your workspace having the variables packed or compressed into the minimum memory required, with no wasted space.

  `pack filename` accepts an optional `filename` for the temporary file used to hold the variables. Otherwise it uses the file named `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, here are some system-specific tips:

- MS-DOS: Add more memory.
- Macintosh: Under MultiFinder, change the application memory size using Get Info on the program icon. Under Single Finder, install more memory.
- VAX/VMS: Ask your system manager to increase your working set.
- UNIX: Ask your system manager to increase your swap space.

  ## See Also

      clear

  (c) Copyright 1994 by The MathWorks, Inc.