How do I increase the heap space for the Java VM in MATLAB?
Ältere Kommentare anzeigen
How do I increase the heap space for the Java VM in MATLAB?
Akzeptierte Antwort
Weitere Antworten (1)
Igor Varfolomeev
am 19 Jun. 2015
Bearbeitet: MathWorks Support Team
am 20 Jun. 2025
Although the Answer by MathWorks Support Team is correct for old matlab versions, here's a cople of notes, concerning more recent versions:
-------
1. First of all, now "Max Java Heap Memory" parameter could be changed via a slider in Preferences->Matlab->General->Java Heap Memory
2. If the maximum value, allowed by this slider, is too small for your needs, (e.g. R2014b only allows me to set it to 49GB, while physically I have 192GB), it could be directly adjusted by editing
"c:\Users\%USERNAME%\AppData\Roaming\MathWorks\MATLAB\R2014b\matlab.prf"
3. Open it with a text editor and modify "JavaMemHeapMax" value. It should look like
JavaMemHeapMax=I190000
4. Restart Matlab
-------
Notes:
- Since this preferences file is in your AppData folder, you even don't need administrative permissions (in contrast to adding "java.opts" to $MATLABROOT, as discussed in the mentioned answer.
- To check the actual value, used by Matlab (in GB):
>> java.lang.Runtime.getRuntime.maxMemory/1e9
- Preferences UI works OK with this new value (thanks, Mathwoks!). It just displays a warning, that it is larger, then recommended.
4 Kommentare
K E
am 15 Feb. 2016
Bearbeitet: MathWorks Support Team
am 24 Jun. 2021
Here is how to find out your machine's max heap size (returns values in bytes while JavaMemHeapMax looks for value in MB). Should I use this value for the Matlab preference above? Why did you enter JavaMemHeapMax=I190000 when you said you had 192GB? Even after I entered my max value of 4GB and it 'took' in Matlab, exporting a figure from the figure window Edit button causes Matlab to freeze for several minutes then issue the error 'Insufficient Java memory to create the output. Increase the Java Heap Size setting in the MATLAB preferences.' I am plotting 2052075 points within the figure. Is 4GB too low to copy that? Didn't see this problem until R2015b.
Namita Vishnubhotla
am 22 Apr. 2016
Bearbeitet: MathWorks Support Team
am 27 Apr. 2023
It is possible that the output requires more than 4GB. If you were able to successfully execute the same code in previous versions of MATLAB, using the same amount of Heap Space, please contact MathWorks Technical Support with valid license number: https://www.mathworks.com/support/contact_us.html?s_tid=contact_us_support_cust_serv
Vandana Ravichandran
am 22 Feb. 2017
Bearbeitet: Vandana Ravichandran
am 22 Feb. 2017
This page from R2016b documentation describes how to set the Java heap space: https://www.mathworks.com/help/matlab/matlab_external/java-heap-memory-preferences.html
Kategorien
Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!