Insufficient Java heap memory to continue operation

4 views (last 30 days)
Dear Community,
I get the following error message again and again after running some saveas(gcf, 'test' , 'pdf'); or print figures.
Insufficient Java heap memory to continue operation
No close all, close gcf, clear all or any tool to clean the java heap http://www.mathworks.com/matlabcentral/fileexchange/36757-java-heap-cleaner helps. I send multiple error report from Matlab directly, but get no response. Last error message I got was:
Error using drawnow
Insufficient Java heap memory to continue operation
Error in prepare (line 44)
drawnow
Error in print>LocalPrint (line 271)
pj = prepare( pj, h );
Error in print (line 240)
LocalPrint(pj);
Error in saveas (line 154)
print( h, name, ['-d' dev{i}] )
Error in myClass/myMethod (line 45)
saveas(gcf, 'test', 'pdf');
If I restart Matlab it works for a couple of runs and then it crashes again. After each run I make a clear all and close all, but both commands does not help. In addition, I put the heap option to the maximum.
Thank you for your help in advance.
Best regards!
  1 Comment
laurie
laurie on 11 Sep 2013
i get this from time to time as well when working with pictures or such. appart from : - running your code on a bigger computer, - restarting Matlab between each run, and - trying to make your code more "memory-friendly" (for example one a picture is saved and you don't need it any more, clean it in your code to save memory ressources) i can't help you much... it just sucks ! sorry

Sign in to comment.

Answers (1)

Ikki kishida
Ikki kishida on 1 May 2015
I got the same error and reached at here. In my case, if I made a figure invisible, the error was't generated.
fig=figure('visible','off');
plot(...);
saveas(fig,'test','png');
close;
I hope it's gonna work for you.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!