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

Issue

Java Application is swapping memory even though the dyno not reached it's memory quota.

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 Java apps, it is unlikely 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.

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support