Java Runtime Environment Settings
In MATLAB®, you can configure the Java® heap size or specify the Java Runtime Environment (JRE™) path.
To access these settings, on the Home tab, in the Environment section, click Settings. Then select MATLAB > General > Java Runtime Environment.
Java Heap Size
You can adjust the amount of memory that MATLAB allocates for Java objects.
Note
The default heap size is sufficient for most cases. Increasing the heap size decreases the amount of memory available for storing data in arrays.
To adjust the heap size, in the Java Heap Size section:
Specify a value using the slider or spinner.
Click OK.
Restart MATLAB.
If the amount of memory you specified is not available upon restart, then MATLAB resets the value to the default and displays an error dialog box. To readjust the value, repeat the previous steps.
If increasing the heap size does not eliminate memory errors, then check your Java code for memory leaks. Eliminate references to objects that you no longer need.
Java Runtime Environment Path
Since R2025a
To set the path to the JRE, in the Java Runtime Environment Path section:
Select one of the version options. For more information about these options, see the
jenvversionargument.Click OK.
Restart MATLAB.