Java heap space out of memory problem

449 views (last 30 days)
Arc Lok
Arc Lok on 2 Jan 2016
Commented: Olarewaju Richard on 9 Apr 2024 at 5:44
Hello guys,
I have a persistant and very annoying problem with matlab. From time to time (quite frequently, a couple of time a day), matlab starts to freeze without any reason and I hear my computer as if there was some heavy process running (even though there is no matlab process running, and many times it just happens at the start of matlab even before I have done anything). Eventually, either matlab crashes and I have to close it or the freeze stops and I get the error below (and after that matlab runs correctly without problem):
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: GC overhead limit exceeded
It seems to have something to do with java heap space, and for no reason there seems to be something running taking all the space ?? I don't really understand what is happening. I have seen this thread : https://www.mathworks.com/matlabcentral/newsreader/view_thread/240599 where somebody has a related issue. I have tried the fix suggested here (<http://www.mathworks.com/matlabcentral/answers/100335-why-do-i-receive-an-error-when-i-execute-the-fetch-statement-on-a-sql-server-database-using-database>) and I have added a java.opts file in my bin/glnx64 of matlab but it does not seem to fix the issue (although I think the error message are slightly different now, see below).
java.lang.OutOfMemoryError: Java heap space
Failed to retrieve Exception Message
java.lang.OutOfMemoryError: Java heap space
Failed to retrieve Exception Message
Exception in thread "Explorer NavigationContext request queue" Exception in thread "HashSessionScavenger-2" java.lang.OutOfMemoryError: Java heap space
java.lang.NullPointerException
Exception in thread "qtp348499891-116" java.lang.OutOfMemoryError: Java heap space
Exception in thread "BayeuxServer@834743137" java.lang.OutOfMemoryError: Java heap space
Exception in thread "qtp348499891-114" java.lang.OutOfMemoryError: Java heap space
Exception in thread "BayeuxServer@1405793791" java.lang.OutOfMemoryError: Java heap space
Exception in thread "TimerQueue" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Thread-292" java.lang.OutOfMemoryError: Java heap space
Additionally, I have the following java log error file written in my home directory:
Operating System: Linux 4.0.7-200.fc21.x86_64 #1 SMP Mon Jun 29 22:11:52 UTC 2015 x86_64
Processor ID: x86 Family 6 Model 58 Stepping 9, GenuineIntel
Host Name:
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "HashSessionScavenger-3"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "HashSessionScavenger-4"
Exception in thread "main" Exception in thread "main"
Do you have any idea on what causes this issue and how I can fix it ? It is really annoying and make matlab very inconvenient to work with...
Thanks in advance for your help
  3 Comments
Vasilisa Skvortsova
Vasilisa Skvortsova on 25 Jul 2020
Edited: Vasilisa Skvortsova on 25 Jul 2020
I've tried to adjust Java Heap memory and disable Control Integration and Matlab immidiately freezes when I start it. I'm using Mac Catalina 10.15.4 and Matlab 2020a. Any chance to solve it?
Jorge Ignacio Cisneros Saldana
Home->Preferences->General->Source I de-selected the Matlab default which was " *Enable MathWorks Source Control Integration" and select " none" instead.
/Applications/MATLAB_R2022a.app/bin/matlab
This both suggestions worked for me also running from terminal in my M1 MAX.
such a pitty to buy such expensive apple computer and being useless. I mentioned i am pursung a Phd and do lots of parallel processing.I contacted Apple support and they said it works with Matlab totally fine, even better than Intel so i went ahead. But I guess they were wrong.

Sign in to comment.

Answers (13)

appBotSmith59
appBotSmith59 on 8 Jun 2016
Called MathWorks Tech Support this morning, 8 June 2016. With MatLab Tech-support trouble-shooting, my issue within R2016a was resolved by changing Matlab's default settings in Preferences as described for Mac OS 10x:
  • going to Home->Preferences->General->Source and
de-selecting the Matlab default which was " *Enable MathWorks Source Control Integration" and
selecting " *none" instead.
According to MathWorks Tech-Support Rep, MathWorks made the " Enable...Source Control" the default setting starting with the MatLab R2014b release. In my case, MatLab was trying to integrate with GIT which caused extended processing until the "Out-of-Memory" error.
  4 Comments
Al in St. Louis
Al in St. Louis on 1 Apr 2021
This fixed my issue with R2021a.
Jinqi Liu
Jinqi Liu on 17 Aug 2021
Hi, do you know how to fix the error:
render process terminated: null
java.lang.NoSuchFieldError: TS_PROCESS_OOM
I have checked this error and it shows something to do with limited memory.

Sign in to comment.


Hernan Gonzalez
Hernan Gonzalez on 9 Feb 2018
MATLAB R2017a, Mac version.
The solution for me was to increase java heap space: Preferences/General/Java Heap Memory
  6 Comments
mats lindberg
mats lindberg on 12 Jan 2022
Worked for me on R2020b, windows
Bill Tubbs
Bill Tubbs on 2 Apr 2022
I increased the Java heap space from 128 to 2048 MB and it didn't solve the problem for me. Just takes even longer in the "busy" state before giving up. What levels are people choosing?

Sign in to comment.


Yulin Chang
Yulin Chang on 24 Mar 2016
I am having a similar problem on my Mac ( MATLAB slow/no response with high CPU usage ). Anybody has a solution for this problem?

Mehdi Adibi
Mehdi Adibi on 13 Nov 2019
I have the same problem with 9.1.0.441655 (R2016b) on win10. I increased the Java memory heap to 384. Also Home->Preferences->General->Source I de-selected the Matlab default which was " *Enable MathWorks Source Control Integration" and select " none" instead. None worked for me and I can not work with matlab this way.
It is a shame such an expensive product is crap .. worthless.

afrazkhan34@gmail.com khilji
hi arc lok!ur program crashes due to unresponsiveness of the program their could be many reasons try following methods. 1)if u use 64-bit windows then install 64 bit application else install 32 bit version of application. 2)if ur program was stable and now due to any reason it is try reinstalling application. 3)the also arises due using incompatible software version with matlab .Try using compatible compiler with matlab. if error still arises try the following link.hope this helps. Goodluck! http://javarevisited.blogspot.com/2011/09/javalangoutofmemoryerror-permgen-space.html

Arc Lok
Arc Lok on 3 Jan 2016
First of all thanks for your answer :) For your advices: 1) I am actually working on linux (fedora 21 64-bits) and matlab is installed in 64 bits as well 2) Actually I don't remember the program being stable, previous version I used (matlab 2011b if i remember well) was working correctly as far as I remember but as soon as I switched to matlab 2015a the problem started 3) what do you mean byt using compatible compiler with matlab ?
  1 Comment
Namira
Namira on 31 May 2016
I have also faced the same problem. I am using matlab2015a. It is really annoying. If you can solve the problem please inform me. Thanks.

Sign in to comment.


afrazkhan34@gmail.com khilji
For executation of certain programs hving libraries from different languages like java u need a compiler. that compiler must b compatible with matlab use the "mex -setup" command to setup a compiler in matlab(in case u already hv any else download nd install the supported one set it up using above mentioned command nd follow the instructions.) The compatibility issue might b responsible fr memory dump. if the problem still persists then try changing the version of matlab u use as u mentioned"this error arrised in matlab 2015a" hope this works fr u!good luck!.

appBotSmith59
appBotSmith59 on 8 Jun 2016
I encountered this error today [7 June 2016] using MatLab R2016a.
In the most recent past, I had a similar error in Android Studio which required increasing memory in a config file. Here's a link, http://lifeofcoding.com/2015/01/19/How-to-increase-Android-studio-memory-limit-in-Mac/. This worked for the Android Studio issue.
Does MathWorks have a recommended solution?
  1 Comment
ahp ahp123
ahp ahp123 on 1 May 2017
Edited: Walter Roberson on 9 Feb 2018
I've faced with this problem too, I was using 2015a which after some while I faced with that and then installed 2016a but the error remains.
I changed the version of java that matlab used to 1.8. but the matlab doesn't work correctly.
I think support team should involve. actually I can't work with matlab now.
------------------------------------------------------------------------
std::terminate() detected at Fri Apr 14 09:22:26 2017
------------------------------------------------------------------------
Configuration:
Crash Decoding : Disabled
Crash Mode : continue (default)
Current Graphics Driver: NVIDIA Corporation GeForce GTX 960M/PCIe/SSE2 Version 4.5.0 NVIDIA 375.39
Current Visual : 0x6b (class 4, depth 24)
Default Encoding : UTF-8
GNU C Library : 2.23 stable
Host Name : ahp
MATLAB Architecture : glnxa64
MATLAB Root : /home/ahp/MatlabInstallationDirec
MATLAB Version : 8.6.0.267246 (R2015b)
OpenGL : hardware
Operating System : Linux 4.4.0-72-generic #93-Ubuntu SMP Fri Mar 31 14:07:41 UTC 2017 x86_64
Processor ID : x86 Family 6 Model 94 Stepping 3, GenuineIntel
Virtual Machine : Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
Window System : The X.Org Foundation (11804000), display :1
Fault Count: 1
Abnormal termination:
std::terminate()
Register State (captured):
RAX = 00007f63b4957460 RBX = 00007f63e6ebd888
RCX = 000000000000000a RDX = 00007f63e6eacb78
RSP = 00007f63b4957270 RBP = 00007f63b4957630
RSI = 0000000000000000 RDI = 00007f63b4957280
R8 = 0000000000000000 R9 = 00007f63ebd77740
R10 = 00007f63e6ad8588 R11 = 00007f63b49572f4
R12 = 00007f63e6ecd8c0 R13 = 00007f63b4958270
R14 = 00007f63b4958250 R15 = 00007f63b4958630
RIP = 00007f63e6bbbb0e EFL = 00007f63b4957488
CS = a94f FS = ec78 GS = 7f63
Stack Trace (captured):
[ 0] 0x00007f63e6bbbb0e /home/ahp/MatlabInstallationDirec/bin/glnxa64/libmwfl.so+00969486 _ZN2fl4diag5linux6x86_6412context_base12capture_dataEv+00000030
[ 1] 0x00007f63e6bb8fe4 /home/ahp/MatlabInstallationDirec/bin/glnxa64/libmwfl.so+00958436
[ 2] 0x00007f63e25f0845 /home/ahp/MatlabInstallationDirec/bin/glnxa64/libmwmcr.so+00784453
[ 3] 0x00007f63e25f2740 /home/ahp/MatlabInstallationDirec/bin/glnxa64/libmwmcr.so+00792384
[ 4] 0x00007f63e25f2831 /home/ahp/MatlabInstallationDirec/bin/glnxa64/libmwmcr.so+00792625
[ 5] 0x00007f63e25f2bb3 /home/ahp/MatlabInstallationDirec/bin/glnxa64/libmwmcr.so+00793523
[ 6] 0x00007f63e25f2c23 /home/ahp/MatlabInstallationDirec/bin/glnxa64/libmwmcr.so+00793635
[ 7] 0x00007f63eba8c376 /usr/lib/x86_64-linux-gnu/libstdc++.so.6+00586614
[ 8] 0x00007f63eba8c3c1 /usr/lib/x86_64-linux-gnu/libstdc++.so.6+00586689
[ 9] 0x00007f63eba8c5d9 /usr/lib/x86_64-linux-gnu/libstdc++.so.6+00587225
[ 10] 0x00007f63d5c50d6e /home/ahp/MatlabInstallationDirec/bin/glnxa64/libmwgui.so+00904558 _ZN11gui_objects11Rectangle2dC1Edddd+00000062
[ 11] 0x00007f63d5c1c2c1 /home/ahp/MatlabInstallationDirec/bin/glnxa64/libmwgui.so+00688833 _ZN11gui_objects4font16PlainTextHandler21validateLogicalBoundsEv+00000737
[ 12] 0x00007f63d5c1c8de /home/ahp/MatlabInstallationDirec/bin/glnxa64/libmwgui.so+00690398 _ZN11gui_objects4font16PlainTextHandler16getLogicalBoundsEv+00000030
[ 13] 0x00007f6293d3fc2d /home/ahp/MatlabInstallationDirec/bin/glnxa64/libmwosgserver.so+02018349 _ZNK2hg14openscenegraph14OsgSceneServer27getTextLogicalBoundsBackEndERKN11gui_objects6CookieERKNS2_4font11StringPropsEbdRKNS6_11InterpreterESt6vectorINS2_11UTF16StringESaISE_EE+00000221
[ 14] 0x00007f6293d4aad5 /home/ahp/MatlabInstallationDirec/bin/glnxa64/libmwosgserver.so+02063061 _ZN2hg19OsgSceneServerProxy28getTextLogicalBoundsCallbackEv+00000101
[ 15] 0x00007f63a661e844 /home/ahp/MatlabInstallationDirec/bin/glnxa64/libnativehg.so+00063556 Java_com_mathworks_hg_uij_TextBoundsRequestHandler_getTextLogicalBoundsCallback+00000020
[ 16] 0x00007f63bd012d98 <unknown-module>+00000000
[ 17] 0x00007f63bd006058 <unknown-module>+00000000
[ 18] 0x00007f63bd006058 <unknown-module>+00000000
[ 19] 0x00007f63bd006706 <unknown-module>+00000000
[ 20] 0x00007f63bd006706 <unknown-module>+00000000
[ 21] 0x00007f63bd0068e1 <unknown-module>+00000000
[ 22] 0x00007f63bd006233 <unknown-module>+00000000
[ 23] 0x00007f63bd006058 <unknown-module>+00000000
[ 24] 0x00007f63bd006058 <unknown-module>+00000000
[ 25] 0x00007f63bd0068e1 <unknown-module>+00000000
[ 26] 0x00007f63bd006058 <unknown-module>+00000000
[ 27] 0x00007f63bd56f758 <unknown-module>+00000000

Sign in to comment.


Seyed Mostafa Mousavi Kahaki
On the Home tab, in the Environment section, click Preferences. Select MATLAB > General > Java Heap Memory. Select a Java heap size value using the slider or spin box. Note. ... Click OK. Restart MATLAB.
  1 Comment
Olarewaju Richard
Olarewaju Richard on 9 Apr 2024 at 5:44
Thank you Seyed Mostafa Mousavi, your comment was helpful. God bless you

Sign in to comment.


Alexandre3
Alexandre3 on 6 Aug 2019
I had a similar problem when I passed from Matlab 2017b to Matlab 2018b. Specially when using Parallel Run, 2018b was freezing and then crashing. Then, I noticed that the default memory heap value was much higher than the one in 2017b. So, I decided to lower the heap memory in order to use the same as in the previous version (2017b). After that, everything worked just fine.
  1 Comment
Furqan Hashim
Furqan Hashim on 7 Jan 2021
Edited: Furqan Hashim on 7 Jan 2021
Is there a reason why reducing helped instead on increasing heap size?

Sign in to comment.


kanika bhalla
kanika bhalla on 24 Jun 2021
I had similar problem and got solved by increasing the Java heap memory. Thank you all for all of your answers.

Jinqi Liu
Jinqi Liu on 17 Aug 2021
Hi, does anyone know how to fix this error:
render process terminated: null
java.lang.NoSuchFieldError: TS_PROCESS_OOM
I have checked this error and it shows something to do with limited memory.
I had increased the Java memory (MATLAB > General > Java Heap Memory). Also Home->Preferences->General->Source select " none". None of them worked for me and I can not operation my model.

Lucky
Lucky on 13 Sep 2022
List<String[]> csvBody = reader.readAll();.
This consumes a lot of info if you're reading a big file.
Instead, read each row individually and then write each one individually:
String[] strArray;
while ((strArray = reader.readNext()) != null) {
// ...
writer.writeNext(strArray);
}

Community Treasure Hunt

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

Start Hunting!