Outofmemory in grails plugin


(Benjamin Garrett) #1

So I’ve done searches on the OutOfMemory issue with the grails/ gradle plugin and I’ve tried everything that I’ve come across to no avail. I am getting PermGen when I run grails-test-app and I get Out of heap space when I run grails-run-app. However, the test-app and run-app grails commands run fine when I don’t use gradle and stick to pure grails commands.

Here is what I’ve tried so far based on google searches:

GRAILS_OPTS=-Xmx1024m -Xms256m -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+HeapDumpOnOutOfMemoryError
GRADLE_OPTS (same as above)
org.gradle.jvmargs (same as above) in gradle.properties

This link https://github.com/grails/grails-gradle-plugin/issues/21 said to use

task 'run-app'(type: GrailsTask) {
  command "run-app"
  jvmOptions {
      jvmArgs '-Xms32m -Xmx1524m -XX:PermSize=32m -XX:MaxPermSize=512m -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC -XX:+UseParNewGC'.split(' ')
      // you could also use the memory properties on JavaForkOptions directly;
      // see http://www.gradle.org/docs/current/javadoc/org/gradle/process/JavaForkOptions.html
  }
}

But when I run that I get:

Could not find method command() for arguments [run-app] on root project

I also found this: http://forums.gradle.org/gradle/topics/_system_out_java_lang_outofmemoryerror_permgen_space

which said to use:

test {
  jvmArgs "-XX:MaxPermSize=256m"
}

but when I tried that I get:

Could not find method test() for arguments [build_69mrpqlj51u7k6kt55e123k2kk$_run_closure4@eca4aae] on root project

Any ideas on what else I could try? Thanks in advance!

Mac OS X 10.6.8 Gradle 1.8 Using groovy version 2.1.6 Using grails version 2.2.4 java version “1.6.0_51” org.grails:grails-gradle-plugin:2.0.0-SNAPSHOT


(alan.mosely) #2

I use this which applies to any Grails task, works using Gradle 1.9-rc-3, Grails 2.3.0 and the grails-gradle-plugin 2.0.0-SNAPSHOT:

import org.grails.gradle.plugin.GrailsTask
tasks.withType(org.grails.gradle.plugin.GrailsTask) { Task t ->
    t.jvmOptions {
        jvmArgs "-Xmx512m", "-XX:MaxPermSize=512m"
    }
}