Java Heap Space Memory Issue

3 views (last 30 days)
Furqan Hashim
Furqan Hashim on 9 Jan 2021
This question has been asked by others as well. But solution in majority of those questions worsened the situtation in my case instaed of improving.
I have a code tha runs a parallel for loop i.e. parfor. In certain cases I get the following error
java.lang.OutOfMemoryError: GC overhead limit exceeded at java.util.Arrays.copyOfRange(Unknown Source) at java.lang.StringBuffer.toString(Unknown Source)
Most of the solution suggested to increase the heap space memory in MATLAB. Once I increased the memory to 2GB from 784MB the frequency at which I was getting this error increased. One thing to note here is that the parallel for loop worked perfectly fine in version 2017b and I started getting this error when I switched to version 2020a. After looking the heap space memory allocated in 2017b I reduced the default memory in 2020a to 384MB similar to default set in 2017b. This solved the issue but I do not understand why reducing helps when most of the solutions suggest to increase the heap space memory.
I want to know a logical reasoning for this behaviour.

Answers (0)


Find more on Startup and Shutdown in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!