title: Memory leak in Controllers in PlayFramework?
body: <p>I have this very simple controller.</p>
  
  <pre><code>package controllers.WebService
  
  import play.api.mvc.{Action, Controller}
  
  object TestLeak extends Controller {
    def index = Action {
      Ok((1 to 100000).mkString)
    }
  }
  </code></pre>
  
  <p>I open it with my browser and mem consumption in my system is 2516MB.
  Every time i refresh the page memory goes up 1-2MB on each refresh. You may say it's the browser's fault but i hit it from another PC and same results. Also ab bench confirms it. -c 100 -n 1000 launches memory consumption at 600mb. </p>
  
  <p><strong>And that memory allocation never goes down</strong></p>
  
  <p>Using System.gc() solves the problem but then I have really low performance. What is going on?</p>
  
  <p>Same problem with Akka.future and scala.future and async. No other imports or trait are included. just what you see.</p>
  
  <p>I have this problem for a while now and cannot deploy to Heroku without System.gc(). Any solutions?</p>
  
  <p>UPDATE
  Actually JAVA_OPTS are not used by heroku (silly me) you have to declare it to Procfile </p>
  
  <pre><code>web: target/start -Dhttp.port=${PORT} ${JAVA_OPTS} ... 
  
  JAVA_OPTS: -Xmx384m -Xss512k -XX:+UseCompressedOops -Dfile.encoding=UTF8
  </code></pre>
  
  <p>Not memory consumption never goes above 500 (heroku limit)</p>
  
  <p>Thanks you the time eveyone</p>