Programming and Data Types | ![]() ![]() |
Making Efficient Use of Memory
This section discusses how to conserve memory and improve memory use. Topics include
For more information on memory management, see Technical Note 1106: "Memory Management Guide", at the following URL:
http://www.mathworks.com/support/tech-notes/1100/1106.shtml
The following functions can help you to manage memory use in MATLAB:
whos
shows how much memory has been allocated for variables in the workspace.
pack
saves existing variables to disk, and then reloads them contiguously. This reduces the chances of running into problems due to memory fragmentation.
clear
removes variables from memory. One way to increase the amount of available memory is to periodically clear
variables from memory that you no longer need.
save
selectively stores variables to the disk. This is a useful technique when you are working with large amounts of data. Save data to the disk periodically, and then clear
the saved data from memory.
load
reloads a data file saved with the save
function.
quit
exits MATLAB and returns all allocated memory to the system. This can be useful on UNIX systems as UNIX does not free up memory allocated to an application (e.g., MATLAB) until the application exits.
Note
save and load are faster than the MATLAB low-level file I/O routines. save and load have been optimized to run faster and reduce memory fragmentation.
|
![]() | Viewing profile Results | Ways to Conserve Memory | ![]() |