Change Java Heap Memory Settings Without Starting Matlab?

조회 수: 16 (최근 30일)
Brady Jackson
Brady Jackson 2013년 5월 2일
I am running Matlab R2012a on a 32 bit Linux box (Ubuntu version 10.04). I recently set the Java Heap Memory settings to ~ 6 GB, as I had forgotten that this machine was a 32 bit build. When I try to launch matlab from the command line now (matlab -nosplash), I get an error:
Invalid maximum heap size: -Xmx6057m
The specified size exceeds the maximum representable size.
Fatal Error on startup: Unable to start the JVM because of an invalid Java option.
I did some Googling and found out that the problem is my available Java heap space can't exceed 1.6 GB since this is a 32 bit machine, which is fine. However, I cannot restart matlab to get to the preferences menu to reset the number to something more reasonable (like 1.5 GB), since it keeps crashing out on launch with the above error.
Is there a configuration file somewhere in my Matlab directory where this preference value gets saved, so I can just manually rewrite the config file and start Matlab again?
Or is there a way to force it to reset to the default allocated Java Heap Memory size?
Thanks for any answers, Brady C. Jackson
  댓글 수: 1
Brady Jackson
Brady Jackson 2013년 5월 2일
For what it's worth, I tried placing the file 'java.opts' in my $MATLABROOT/bin/$ARCH directory and added the two lines to it:
-Xmx1512m
-Xms128m
I get the same error as before, except now it tells me to check my java.opts file. It seems like, maybe, my specified options are getting overwritten somehow? Is there a better place to set this option for verison R2012a?
New Error:
Invalid maximum heap size: -Xmx6057m
The specified size exceeds the maximum representable size.
Fatal Error on startup: Unable to start the JVM because of an invalid Java option.
Please check your java.opts file.

댓글을 달려면 로그인하십시오.

채택된 답변

Brady Jackson
Brady Jackson 2013년 5월 2일
Alright, I found the answer to both of my queries above. For R2012a, at least (I can't speak to other versions, the java heap settings in the matlab.prf file seem to override anything you put in java.opts. The trick is, this file lives in your preferences directory which may or may not live under your $MATLABROOT directory.
In my case, my preferences file was stored in ~/.matlab/R2012a/matlab.prf.
I figured this out by launching matlab from a command line with no java virtual machine running, and running the prefdir command:
matlab -nodisplay -nodesktop -nosplash -nojvm
prefidr
Once I figured that out, I edited the matlab.prf file and scrolled to the bottom to find:
JavaMemHeapMax=I6057
Changing that line to the following:
JavaMemHeapMax=I1512
... fixed my problem and reset the slider under the graphical Java Heap Memory settings in the Preferences GUI back to 1512. So, use the .prf file for R2012a version.
Cheers!
Brady C. Jackson
  댓글 수: 1
Christopher
Christopher 2013년 8월 1일
Thanks so much for posting this, saved my skin when I foolishly increased my Java Heap. I thought that because I have a 64bit system that I would be fine with a 4gb heap max, but I forgot that I was running 32bit Matlab and so I ran into the same problem you had. On Windows 7 I found the matlab.prf file under C:\Users\USERNAME\AppData\Roaming\MathWorks\MATLAB\R2013a.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by