Configure Java GC to throw OOME right away and not slow down indefinitely

I noticed that sometimes, when the memory is almost exhausted, the GC tries to terminate at all costs of performance (it almost freezes the program, sometimes a few minutes ), and just throw OOME (OutOfMemoryError) immediately.

Is there a way to tune GC on this aspect?

Slowing the program down to zero speed makes it inactive . In some cases, it would be better to have the answer "I'm dead," and not at all any answer.

+5
source share
3

- , , JVM.

:

  • Hotspot VM ( ) Java 6
  • UseGCOverheadLimit ( , , )

OOM , : 98% GC 2% , OOM.

( , 98%) , , , , .

, ; , .

JVM HotSpot, .

+7

, Java , .

, . Runtime.freeMemory() " " , .

, , , .

+2

, Java, GC, OutOfMemoryException, - , .

, , .

, , :

  • , , .
  • , (, 100 , ) , .
  • , !

: , . , , , , . incase - , , GC, ​​ , -, . -, , GC, .

Regardless, these are just general ideas from my head on how to improve performance when allocating memory. What I'm trying to do is that the question of how to raise the OutOfMemory error faster and not allow the Java GC to best try to free up space on the heap is not a great IMO idea. Optimize your application.

+1
source

All Articles