From the continuous increase in memory usage without significant drops (often referred as a "memory ramp") suggests that your Grails application might be experiencing a memory leak or inefficient GC. Here is the breakdown of possible reasons:
1. The app might be holding reference to the objects that are no longer needed, preventing the GC from reclaiming memory.
2. The GC might not be running efficiently, or it might not be reclaiming memory aggressively enough.
3. Object might be retained longer than necessary due to caching mechanism, session management, or improper handling of collections.
There are multiple ways to diagnose and mitigate:
• Analyse Heap Dump when the memory usage is high. You could use tools like VisualVM or YourKit to analyze heap dump.
• Enabling GC logging to get insights into how the GC is performing. Add to JVM options
-XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:/path/to/gc.log
• Depending on your JVM and application worklaod, you can experiment with different garbage collectors.
-XX:+UseG1GC -XX:MaxGCPauseMillis=200
• Check for common memory leak patterns such as - static collections or caches that grow over time, long-lived threads that hold onto large objects. etc