The MATLAB® software generates an
whenever it requests a segment of memory from the operating system
that is larger than what is available. When you see the
use any of the techniques discussed under Strategies for Efficient Use of Memory to help optimize the
available memory. If the
still appears, you can try any of the following:
Compress data to reduce memory fragmentation.
If possible, break large matrices into several smaller matrices so that less memory is used at any one time.
If possible, reduce the size of your data.
Make sure that there are no external
constraints on the memory accessible to MATLAB. (On UNIX® systems,
limit command to check).
Increase the size of the swap file. We recommend that you configure your system with twice as much swap space as you have RAM. See Increasing System Swap Space, below.
Add more memory to the system.
The platforms and operating systems that MATLAB supports have different memory characteristics and limitations. In particular, the process limit is the maximum amount of virtual memory a single process (or application) can address. On 32-bit systems, this is the most important factor limiting data set size. The process limit must be large enough for MATLAB to store all of the data it is to process, any MATLAB program files, the MATLAB executable itself, and additional state information.
Where possible, choose an operating system that maximizes this number, that is, a 64-bit operating system. The following is a list of MATLAB supported operating systems and their process limits.
|Operating System||Process Limit|
32-bit Microsoft® Windows® XP, Windows Vista™, Windows 7 and higher
32-bit Windows XP with 3 GB
64-bit Windows or Linux® running 32-bit MATLAB
|≤ 4 GB|
64-bit Windows, Apple Mac, or Linux running 64-bit MATLAB
To verify the current process limit of MATLAB on Windows systems,
Maximum possible array: 583 MB (6.111e+008 bytes) * Memory available for all arrays: 1515 MB (1.588e+009 bytes) ** Memory used by MATLAB: 386 MB (4.050e+008 bytes) Physical Memory (RAM): 2014 MB (2.112e+009 bytes) * Limited by contiguous virtual address space available. ** Limited by virtual address space available.
When called with one output variable, the
returns or displays the following values. See the function reference
memory to find out how
to use it with more than one output.
|memory Return Value||Description|
|Size of the largest single array MATLAB can currently create|
|Total size of the virtual address space available for data|
|Total amount of memory used by the MATLAB process|
View the value against the Total entry in the Virtual Memory
section. It is shown as 2 GB in the table, which is the default on Windows XP systems.
On UNIX systems, see the
to view and set user limits including virtual memory.
On UNIX systems, you can increase the workspace size by
approximately 400 MB if you start MATLAB without the Java® JVM™.
To do this, use the command line option
start MATLAB. This also increases the size of the largest contiguous
block (and therefore the largest matrix) by about the same.
-nojvm comes with a penalty in that
you lose many features that rely on the Java software, including
the entire development environment.
Starting MATLAB with the
does not save any substantial amount of memory.
Shutting down other applications and services (for example,
msconfig on Windows systems) can help
if total system memory is the limiting factor, but usually process
limit (on 32-bit machines) is the main limiting factor.
The total memory available to applications on your computer is comprised of physical memory (RAM), plus a page file, or swap file, on disk. The swap file can be very large (e.g., 16 TB on 32-bit Windows, 512 TB on 64-bit Windows). The operating system allocates the virtual memory of each process to physical memory or to the swap file, depending on the needs of the system and other processes.
Most systems allow you to control the size of your swap file. The steps involved depend on the system you are running on.
Note: There is no interface for directly controlling the swap space on Macintosh OS X systems.
Use the Windows Control Panel to change the size of the virtual memory paging file on your system. For more information, refer to the Windows help.
You can change your swap space by using the
For more information, type
man followed by the
command name at the Linux prompt.
Microsoft Windows XP systems can allocate 3 GB (instead
of the default 2 GB) to processes, if you set an appropriate switch
boot.ini file of the system. MathWorks® recommends
that you only do this with Windows XP SP2 systems or later. This
gives an extra 1 GB of virtual memory to MATLAB, not contiguous
with the rest of the memory. This enables you to store more data,
but not larger arrays, as these are limited by contiguous space. This
is mostly beneficial if you have enough RAM (e.g., 3 or 4 GB) to use
After setting the switch, confirm the new value of the virtual
memory after restarting your computer and using the
[userview systemview] = memory; systemview.VirtualAddressSpace ans = Available: 1.6727e+009 % Virtual memory available to MATLAB. Total: 2.1474e+009 % Total virtual memory
For more documentation on this option, use the following URL:
Similarly, on machines running Microsoft Windows Vista and Windows 7 and higher, you can achieve the same effect by using the command:
BCDEdit /set increaseuserva 3072
For more information on this option, go to the following website:
There are no functions implemented to manipulate the way MATLAB handles Microsoft Windows system resources. Windows systems use these resources to track fonts, windows, and screen objects. Resources can be depleted by using multiple figure windows, multiple fonts, or several UI controls. One way to free up system resources is to close all inactive windows. Windows system icons still use resources.