I have a Play Framework WebApp which needs a lot of a few hundret MB of memory for certain requests.
Those memory-intensive operations do not occur very often (like once or twice a day), but can't be moved to a cronjob (or something similar), as a user makes a request and expects an immediate answer.
It all seems to work fine, except this: I'd expect my WebApp to free up some memory/heap space every now and then, but for some readon the heap space keeps growing and growing.
I supply the following two parameters for memory limits:
-Xms100m
-Xmx3000m
-XX:MaxHeapFreeRatio=60
-XX:MinHeapFreeRatio=20
-XX:+UseConcMarkSweepGC
-XX:+CMSIncrementalMode
My heap usage looks like this:
The heap size grows up to 1.6 gb (which is the maximum amount of memory the WebApp uses) and it's not freed even if the "Used heap" drops back to around 150-200 mb, which seems to be the "idle level" after the GC did its work.
VisualVM offers a "Process GC" button to initiate garbage collection manually. If I do this, heap space is freed:
Should I choose another GC strategy or "help" the JVM somehow to understand at which point it needs to perform a GC? Is there a way to automate things?