Technical Solutions
How do I increase the heap space for the Java VM in MATLAB 6.0 (R12) and later versions?
Date Last Modified: 28 Jul 2008
| Solution ID: | 1-18I2C | |
| Product: | MATLAB | |
| Reported in Release: | R12 | |
| Platform: | All Platforms | |
| Operating System: | All OS |
Subject:
How do I increase the heap space for the Java VM in MATLAB 6.0 (R12) and later versions?
Problem Description:
I would like to increase the Java VM heap space in MATLAB 6.0 (R12) and later versions.
Solution:
As of MATLAB 6.0 (R12), you can increase the heap space for the Java Virtual machine (VM) as follows: Note: $MATLABROOT is the MATLAB root directory and $ARCH is your system architecture. You can find the MATLAB root directory on your machine, by typing at the MATLAB Command Prompt:
matlabroot
You can find the system architecture by executing the following at the MATLAB Command Prompt:
computer('arch')
To create a java.opts file, you just need to create a text file and name it as java.opts.
2. The contents of the java.opts file consist of the following lines of text: For the JVM versions 1.2 and up: For the 1.1.8 JVM: This will give you 256MB of JVM memory and you can adjust the parameter as needed. For the 1.3 and 1.2 JVM, our defaults are: For the 1.1.8 JVM (Windows, Linux, Solaris, Alpha, SGI) our defaults are: These are the structure field names in <jni.h> that correspond to -ms and -mx, and the settings above are roughly 16MB and 64MB. To determine the version of Java you are running, type the following at the MATLAB command prompt:
version -java
You can use the following commands to obtain information about the Java heap::
java.lang.Runtime.getRuntime.maxMemory
When the free memory hits zero, Java will double the heap size (up to the maximum setting).In some cases, increasing the Java stack size above a certain limit can cause Java memory problems. See the Related Solution listed below for more information. http://www.mathworks.com/support/bugreports/details.html?rp=398525 |
|
|
Store