MATLAB Memory Overflow Solution Learning notes

Source: Internet
Author: User
Summary of common methods:

1) using Pack:pack, you can export the variables in MATLAB to disk to increase the available memory.

2) Reduce the memory overhead of the variable.

Note: The method of increasing virtual memory is not feasible. 3) 64-bit architecture: 64-bit hardware and software architecture.
4) 3GB switchover (3GB switch): This error will occur if the memory is used more than about 1.7G, regardless of how much memory you have, because you are running MATLAB on Windows. Fortunately now on Windows XP, MATLAB now supports 3GB toggle (3GB switch) boot option (boot option), configuring additional 1GB of addressable memory on each program. This increases the amount of data you can store in MATLAB workspace to about 2.7 GB. This corresponds to a precision value of 3.3 billion. This new chunk of memory and MATLAB use the remaining (memory) is not sequential, so you cannot create an array to fill this space.


5) More efficient optimization scheme adjust the amount of memory the Java Virtual machine can allocate MATLAB java.lang.OutOfMemoryError
Java Virtual machine memory is not enough. You can increase the maximum memory setting.

1. Find the MATLAB root path.

In the MATLAB command line, typing: matlabroot, showing the root path, such as: C:\MATLAB7
2. View the current Java Virtual machine max heap memory, typing: java.lang.Runtime.getRuntime.maxMemory

3. View the Java Virtual Machine version. Typing: Version-java

4. Create a new java.opts file under $MATLAB \bin\ $ARCH path.
$MATLAB is the root path, for example C:\MATLAB7
$ARCH is the system architecture. For example Win32, create a new java.opts file under C:\MATLAB7\bin\win32.

5. Open the Java.opts file with Notepad,
For different versions of the Java Virtual machine, enter:
The following table shows the default settings MATLAB uses for versions of the JVM:

JVM Initial Heap Size Max Heap Size
1.6.0-xms64m-xmx128m (32-bit)-xmx196m (64-bit)
1.5.0-xms64m-xmx96m (32-bit)-xmx128m (64-bit)
1.4.2-xms16m-xmx96m
1.3.1-xms16000000-xmx64000000
1.2.2-xms16000000-xmx64000000
1.1.8-ms16000000-mx64000000

For example, my Java is 1.4.2, in the java.opts file write-xmx96m, save is OK
If an error is entered: warning:failed to start to Java Virtual machine

6. Restart Matlab, typing java.lang.Runtime.getRuntime.maxMemory
Displays the maximum memory change, setting is successful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.