Why does my Java application start swapping memory before I run out of RAM?

Issue

Java Application is swapping memory, even though the dyno has head room for more

Resolution

The Linux operating system will occasionally swap out less frequently used memory pages to disk even when there is sufficient free RAM for the current process. In the case of the Java apps, it is unlike that the swapped pages will include heap space because the JVM uses its own memory management system that touches many different pages as it modifies and garbage collects the heap.

In most cases, the swapped memory is connected to off-heap memory that may have been used by external libraries, JNI, and other components.

If you do not see a degradation of performance, the increase in swap can be ignored.