10

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

weakwire
  • 9,284
  • 8
  • 53
  • 78

2 Answers2

5

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.

Naaman Newbold
  • 3,324
  • 1
  • 21
  • 12
0

I had this issue as well, and answered it here.

I had the same issue. Heroku is telling you the machine is running out of memory, not the Java VM. There is actually a bug in the Heroku Play 2.2 deployment, the startup script reads java_opts, not JAVA_OPTS.

I fixed it by setting both:

heroku config:add java_opts='-Xmx384m -Xms384m -Xss512k -XX:+UseCompressedOops'
heroku config:add JAVA_OPTS='-Xmx384m -Xms384m -Xss512k -XX:+UseCompressedOops'

I also had to set -Xms otherwise I got an error saying the min and max were incompatible. I guess Play2.2 was using a default higher than 384m.

Community
  • 1
  • 1
WearyMonkey
  • 2,519
  • 1
  • 24
  • 22