Memory leak in controllers in PlayFramework?

I have this very simple controller.

package controllers.WebService

import play.api.mvc.{Action, Controller}

object TestLeak extends Controller {
  def index = Action {
    Ok((1 to 100000).mkString)
  }
}

      

I open it with my browser and the memory consumption on my system is 2516 MB. Every time I refresh the memory of the page it increases by 1-2MB on every refresh. You can tell it is a browser bug, but I hit it from another PC and with the same results. This is also confirmed at the stand. -c 100 -n 1000 starts 600mb memory consumption.

And this memory allocation never decreases

Using System.gc () solves the problem, but then I have really poor performance. What's happening?

Same problem with Akka.future and scala.future and async. There are no other imports or features. just what you see.

I have had this problem for a while now and cannot deploy to Heroku without System.gc (). Any solutions?

UPDATE Actually JAVA_OPTS are not used by heroku (by stupid me), you have to declare it in Procfile

web: target/start -Dhttp.port=${PORT} ${JAVA_OPTS} ... 

JAVA_OPTS: -Xmx384m -Xss512k -XX:+UseCompressedOops -Dfile.encoding=UTF8

      

Memory consumption never exceeds 500 (hero limit)

Thank you time eveyone

+3


source to share


1 answer


I don't think it has to do with the game. This seems like normal behavior to me. The JVM does not collect garbage immediately upon request, it decides for itself (based on the gc options that can be changed) when it will collect. Has your app ever crashed because it was out of memory? You need to attach jconsole to it and then run ab with a lot of requests and you will see the memory is eventually freed.



+5


source







All Articles