5

I am trying to deploy very simple Grails 2.3.7 application (several REST controllers and Spring Security REST) on Heroku and constantly getting

Error R14 on Heroku (Memory Quota Exceeded)
Process running mem=906M(177.1%)

My BuildConfig.groovy contains:

grails.project.fork = [
    test: false,
    run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
    war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
    console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]

Why does Grails consume so much memory and how can i tune my BuildConfig.groovy to fit into 512mb Heroku limitation?

UPD May be the issue is in my travis.yml file? It looks like this:

language: groovy
jdk:
- oraclejdk7
before_script:
- chmod +x grailsw
script: ./grailsw clean
  && ./grailsw refresh-dependencies
  && ./grailsw test-app
before_deploy:
- chmod +x grailsw
deploy:
  provider: heroku
  app: igetit
  on: develop
turboDi
  • 137
  • 9
  • I'm not sure, but it might be that the maxPerm (Perm Gen) and the maxMemory (Heap size) are added together. An approach in this could be to reduce the maxMemory to 512, and keep the maxPerm at 256 (maybe you could get it to 192 or something, but you'd have to do some experimenting here) – Erik Pragt Jul 19 '14 at 08:24
  • I know it's strange, but after changing maxMemory to 512 and redeploying memory usage became even more: 934M – turboDi Jul 21 '14 at 08:52
  • How exactly are you deploying your app? Are you deploying the war? Are you running run-war? Anything else? – Erik Pragt Jul 21 '14 at 09:17
  • I use Grails buildpack of Travis CI. It writes `./grailsw war`, which, I suppose, creates war file and deploys it – turboDi Jul 21 '14 at 18:24
  • 1
    If you use `grails war`, then these memory settings are not used. They are only used for forked execution, for example when running test-app or run-war. Your memory settings are probably controlled by your JAVA_OPTS. I'm not familiar with Heroku, but you could take a look here: http://stackoverflow.com/questions/15555108/heroku-jvm-tuning – Erik Pragt Jul 21 '14 at 18:32
  • Thank you! I've tried to add options in linked question and now my total memory usage is about 500 mb. If I could accept your comment as an answer... – turboDi Jul 26 '14 at 09:46

2 Answers2

1

When you don't mention jdk then heroku by default take open-jdk. Just mention the jdk version.

Create a file system.properties in parallel of application.properties and add the following line:

java.runtime.version=1.7

Commit this file and redeploy.

Ref# Grails R14 Error (Memory quota exceeded) on Heroku

MKB
  • 7,587
  • 9
  • 45
  • 71
  • Thanks, but I've already read this article. It doesn't work for me – turboDi Jul 21 '14 at 08:54
  • I have same error few months back and the above procedure some the issue. May be some other issue you have. All the best. – MKB Jul 21 '14 at 08:56
1

My comment as an answer:

If you use grails war, then these memory settings are not used. They are only used for forked execution, for example when running test-app or run-war. Your memory settings are probably controlled by your JAVA_OPTS. I'm not familiar with Heroku, but you could take a look here:

Heroku JVM tuning

Community
  • 1
  • 1
Erik Pragt
  • 13,513
  • 11
  • 58
  • 64