How do I increase the heap space for the Java VM in MATLAB?
Mostrar comentarios más antiguos
How do I increase the heap space for the Java VM in MATLAB?
Respuesta aceptada
Más respuestas (1)
Igor Varfolomeev
el 19 de Jun. de 2015
Editada: MathWorks Support Team
el 20 de Jun. de 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 comentarios
K E
el 15 de Feb. de 2016
Editada: MathWorks Support Team
el 24 de Jun. de 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
el 22 de Abr. de 2016
Editada: MathWorks Support Team
el 27 de Abr. de 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
el 22 de Feb. de 2017
Editada: Vandana Ravichandran
el 22 de Feb. de 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
Categorías
Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!