Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku memory leak with Play2 scala

Was doing some stretch (ab) test to my 1 heroku dyno and dev database with 20 connections limit.

During the calls (that access database with squeryl the heap allocation is increasing causing R14 (memory more than 512MB))

I cannot seem to reproduce the problem (at that levels at least locally).

Is there any way to get heroku heap dump and analyze it to get some clue?

Is there any known issues with play2, scala, squeryl and heroku memory leak?

Update

If i do System.gc at the end of the controller everything seems to be fine and slower ofc...I create a lot of object at that call but shouldn't heroku's JVM take care of gc? Also if i schedule gc call periodically don't free memory

like image 715
weakwire Avatar asked Nov 13 '12 23:11

weakwire


1 Answers

There's a great article for troubleshooting memory issues on Heroku: https://devcenter.heroku.com/articles/java-memory-issues

In your case, you can add the GC flags to JAVA_OPTS to see memory details. I'd suggest the following flags:

heroku config:add JAVA_OPTS="-Xmx384m -Xss512k -XX:+UseCompressedOops -XX:+PrintGCDetails -XX:+PrintHeapAtGC -XX:+PrintGCDateStamps"

There's also a simple java agent that you can add to your process if you want a little more info from JMX about your memory. You can also take a look at monitoring addons like New Relic if you want to go into more depth, but I think you should be fine with the flags and java agent.

like image 173
Naaman Newbold Avatar answered Oct 13 '22 14:10

Naaman Newbold