How do I increase the heap space for the Java VM in MATLAB?
Afficher commentaires plus anciens
How do I increase the heap space for the Java VM in MATLAB?
Réponse acceptée
Plus de réponses (1)
Igor Varfolomeev
le 19 Juin 2015
Modifié(e) : MathWorks Support Team
le 20 Juin 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 commentaires
K E
le 15 Fév 2016
Modifié(e) : MathWorks Support Team
le 24 Juin 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
le 22 Avr 2016
Modifié(e) : MathWorks Support Team
le 27 Avr 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
le 22 Fév 2017
Modifié(e) : Vandana Ravichandran
le 22 Fév 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
Catégories
En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!