0

I get this error message when the JUnit test executes:

java.lang.OutOfMemoryError: GC overhead limit exceeded

Does the OutOfMemoryError come from an overhead of the garbage collector?

cmdpunk
  • 1
  • 2
  • No. The error is due to GC is too frequent or takes too long during execution. A possible fix is reconfigure the heap, such as enlarging the heap size. – JQian Mar 13 '17 at 21:42
  • The [documentation](https://docs.oracle.com/javase/7/docs/api/java/lang/OutOfMemoryError.html) states clearly: *"Thrown when the Java Virtual Machine cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector"* - so you filled up your heap completely with objects that are still in use – UnholySheep Mar 13 '17 at 21:43

1 Answers1

0

Java provides a garbage collector to automatically look for object's that aren't needed anymore.

All Java objects are stored in your program memory's heap.The heap, which is also referred to as the free store, represents a large pool of unused memory allocated to your Java application.The heap may be quite large, depending on your environment, but there is always a limit to its size.If your program keeps instantiating objects and leaving them on the heap, eventually it will run out of memory.

Aamir M Meman
  • 1,645
  • 14
  • 15