2

After reading article Detecting Java OutOfMemoryError before it happens we have decided to implement such a out of memory detection in our project. Unfortunately with G1 GC it does not work as expected.

The javadoc of used MEMORY_COLLECTION_THRESHOLD_EXCEEDED says
Notification type denoting that the memory usage of a memory pool is greater than or equal to its collection usage threshold after the Java virtual machine has expended effort in recycling unused objects in that memory pool. This notification is emitted by MemoryMXBean. The value of this notification type is java.management.memory.collection.threshold.exceeded.

When using G1 GC the mentioned expended effort in recycling unused objects does not mean full GC. The memory usage measurement is done too often and not only after full GC. It may cause the premature low memory detection.

Did you experience similar problem? Do you have any solution for that?

Idzik
  • 43
  • 2
  • 1
    At least, a collection on the old generation must have happened, for the collection threshold to be crossed and notified. A pure young collection can’t trigger the notification. Besides that, it seems to be a matter of the right threshold, i.e. the notification threshold should be (significantly) higher than the threshold that triggers a concurrent collection (0.65 IIRC). – Holger Nov 02 '20 at 17:03

0 Answers0