0

i have use like this

java -Xmx1G -jar [file].jar but when i run it i got error like this :

Exception in thread "Thread-11" java.lang.OutOfMemoryError: GC overhead limit exceeded

How to fix this problem ?

i have change become java -Xmx2G -jar [file].jar

and here my consist size for thread

public class QueueConst {
    public static int Size_Worker = 300000;
    public static int DELAYED_MESSAGE_Worker = 1000000;
}

so my question is the problem in my heap size or in my QUEUE Size ? thanks all

  • 1
    I've marked the question as a dupe, because as it stands it's very generic: we don't know what technology you use. You show us a couple of constants, but we don't know what they mean (or what technolgy you plug them into), so no answer that's more specific than the linked to one is possible. – Joachim Sauer Dec 06 '20 at 16:16

1 Answers1

0

Your application uses more memory than the available, causing the Garbage Collector (GC) to try harder to reclaim memory until the CPU spends more time on GC than running your code and the "GC overhead limit exceeded" error occurs.

Your options are:

  1. Provide more memory (by increasing heap size, as you already did with -Xmx2G). At some point you will have to increase your server memory as well.
  2. Use less memory and/or allow GC to reclaim more memory. It's hard to tell how to do that based on your code snippet but you can identify code using excessive memory or spot memory leaks by examining a heap dump (i.e. using VisualVM or Memory Analyzer)
Tasos P.
  • 3,994
  • 2
  • 21
  • 41