Error java.lang.OutOfMemoryError: GC overhead limit exceeded

I get this error message as I execute my JUnit tests:

java.lang.OutOfMemoryError: GC overhead limit exceeded

I know what an OutOfMemoryError is, but what does GC overhead limit mean? How can I solve this?

1 Like

This sounds very interesting. I’d love if you could post some code that generates this.

1 Like

I simply found the problem, that lead to too much memory-usage, near to the limit of the heap. A simple solution could be simply to give some more Heap-memory to the Java-Engine (-Xmx) but this only helps, if the application needs exactly as much memory, as the heap-limit before was set.

1 Like

If you are sure there are no memory leaks in your program, try to:

  1. Increase the heap size, for example -Xmx1g.
  2. Enable the concurrent low pause collector -XX:+UseConcMarkSweepGC.
  3. Reuse existing objects when possible to save some memory.

If necessary, the limit check can be disabled by adding the option -XX:-UseGCOverheadLimit to the command line.

I disagree with the third advice. Reuse existing objects do not save memory (do not leak old objects save memory :slight_smile: Moreover “reuse existing object” was a practice to relieve GC pressure. But it’s NOT ALWAYS a good idea: with modern GC, we should avoid situations where old objects hold new ones because it can break some locality assumptions

1 Like

Just increase the heap size a little by setting this option in

Run → Run Configurations → Arguments → VM arguments

-Xms1024M -Xmx2048M

Xms - for minimum limit

Xmx - for maximum limit

There is no “minimum limit”. -Xms is the initial size.

1 Like

What is the max of maximum limit that could be set??

1 Like

the max is as much as the physical memory of your machine. However, other applications will compete over memory use if you try that.

Can you show a sample example?

For me, the following steps worked:

  1. Open the eclipse.ini file
  2. Change


  1. Restart Eclipse

eclipse.ini file in jdev?

yes. its the same…

The android apps dont have arguments tab…what should we do to achieve this?

1 Like

@rebecca-mason did not mention an Eclipse question, but I’m assuming it to be the same and hence answering

problems unsolved even when the configuration has been changed to this.

problem not yet solved. do you have / know any other way?

You need to increase the memory size in Jdeveloper go to setDomainEnv.cmd.

set WLS_HOME=%WL_HOME%\server    
set XMS_SUN_64BIT=**256**
set XMS_SUN_32BIT=**256**
set XMX_SUN_64BIT=**3072**
set XMX_SUN_32BIT=**3072**
set XMS_JROCKIT_64BIT=**256**
set XMS_JROCKIT_32BIT=**256**
set XMX_JROCKIT_64BIT=**1024**
set XMX_JROCKIT_32BIT=**1024**

if "%JAVA_VENDOR%"=="Sun" (
    set WLS_MEM_ARGS_64BIT=**-Xms256m -Xmx512m**
    set WLS_MEM_ARGS_32BIT=**-Xms256m -Xmx512m**
) else (
    set WLS_MEM_ARGS_64BIT=**-Xms512m -Xmx512m**
    set WLS_MEM_ARGS_32BIT=**-Xms512m -Xmx512m**


set MEM_PERM_SIZE_64BIT=-XX:PermSize=**256m**
set MEM_PERM_SIZE_32BIT=-XX:PermSize=**256m**

if "%JAVA_USE_64BIT%"=="true" (
) else (

set MEM_MAX_PERM_SIZE_64BIT=-XX:MaxPermSize=**1024m**
set MEM_MAX_PERM_SIZE_32BIT=-XX:MaxPermSize=**1024m**

These settings are only specific to your local IDE. This will not work for Prod environment.

1 Like

ok. So any suggestions???