0

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: Heap

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:

Heap with manual GC

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?

Peanut
  • 3,753
  • 3
  • 31
  • 45
  • Not much, really. This is a JVM thing. Don't let it grow to that size in the first place. – Michael Zajac Jun 29 '15 at 18:49
  • @m-z That's easier said than done ;-), but I agree, this would be the perfect solution. Further debugging showed that I actually do not need that much heap space. I'm investigating whether it's actually the JVM not freeing the heap space, or some sort of caching mechanism of play which prevents the JVM from doing it's job. I'll update my questions with my findings. – Peanut Jun 30 '15 at 07:03
  • I agree. This is a duplicate of the other question. I added an answer to the other question which solves this one as well: http://stackoverflow.com/a/31294584/596532 Setting the right GC and performing manual GC at some key points prevents the app from consuming this much memory. Memory consumption stays low if the GC is performed at the right time(s). – Peanut Jul 22 '15 at 11:44

0 Answers0