For some reason, G1 is deciding to increase the committed old generation memory (although the used memory does not increase) and decrease the Eden generation committed memory (consequently the usable space). It seems to be causing a spike in GC's young generation runs and making the application unresponsive for some time.
We also can see a spike in CPU usage and the total committed virtual memory in the machine (which gets bigger than the total physical memory). It is also possible to see a spike in disk usage and swapout/swapin.
My questions are:
JVM version: Ubuntu, OpenJDK Runtime Environment, 11.0.11+9-Ubuntu-0ubuntu2.20.04
EDIT: Seems that what is causing the memory spike is a sudden increase in the off-heap JVM direct buffer memory pool. The image below shows the values of 4 metrics: os_committed_virtual_memory (blue), node_memory_SwapFree_bytes (red), jvm_buffer_pool_used_direct (green) and jvm_buffer_pool_used_mapped (yellow). The values are in GB.
I'm still trying to find what is using this direct buffer memory and why it has such an effect on the heap memory.
The issue was caused by a memory leak related to direct memory usage. An output stream was not being closed after being used.