Volume 5, Number 1
Memory Issue of Matlab R13 in Sweetgum
by Taner Pirim
Currently, Matlab Ver. 6 Release 13 had been installed on Sweetgum due to the fact that Matlab doesn't support SGI systems on new versions
such as Matlab Ver. 7 Release 14. However, a technical memory issue with the old version of Matlab 6 has been arisen regarding the calculation
of huge matrix creations and calculations.
One cause of 'Out of Memory' errors is that your system has in fact run out of heap space to hold all of your variables. This means that there is no unallocated virtual address space on your computer for MATLAB to use, and therefore no new variables can be created.
The second major cause of 'Out of Memory' errors is memory fragmentation. This means that there is memory available, but there is no contiguous piece of memory that is large enough to hold the specified variable. When virtual memory is used and freed during normal operation of MATLAB, memory becomes fragmented. This means that the amount of total free memory may be greater than the amount of contiguous free memory. Since a matrix in MATLAB must be stored in a contiguous block of virtual memory, the largest matrix that can be created at a particular point in time is limited by the amount of contiguous free virtual address space.
There are a number of measures you can take to increase the amount of memory available for code generation.
One of the most important measures is to make sure you are running the most recent MATLAB release. However, for Matlab Ver. 6 Release 13,
there are five functions that a user can use to free and defragment MATLAB workspace memory to prevent the causes of issues above
for the Matlab Version 6 Release 13. These five functions are; CLEAR Removes variables from memory
PACK Writes existing variables off to disk, and then reloads them contiguously
QUIT Exits MATLAB and returns all allocated memory to the system
SAVE Selectively stores variables to disk
LOAD Reloads a data file saved with the SAVE command
For more information, you can visit Memory Management Guide in
Technical Product Support webpage of Mathworks.
In Matlab 7 Release 14, the memory limitations encountered that cause "disk swapping" or the Real-Time Workshop code generation to abort
could be resolved without re-modification of the Real-Time Workshop code. One of the solutions is to use the MATLAB_MEM_MGR environment variable
to control the MATLAB memory manager. By default, MATLAB uses the 'cache' memory manager.
For reduced memory usage, you should use the following settings:
If you start MATLAB from a Command Prompt window or from a batch file (.bat),
you can set the environment variable before calling MATLAB with:
Alternatively, you can set the environment variable 'MATLAB_MEM_MGR' to 'fast' by using the 'My Computer' icon.
UNIX Platforms: You can set the environment variable 'MATLAB_MEM_MGR' to 'compact'.
For example, with csh (c shell), your .cshrc file would contain:
setenv MATLAB_MEM_MGR compact
For more information on the various solutions, you can visit
Technical Solutions on Memory.
For further assistance, contact the MCSR consultants.