Skip to content

Troubleshooting

Phil Leggetter edited this page Jan 20, 2014 · 1 revision

java.lang.OutOfMemoryError when running ./gradlew assemble

When running the ./gradlew assemble command it is possible that you will see an error similar to the following:

:brjs-core:javadoc
javadoc: error - java.lang.OutOfMemoryError: Please increase memory.
For example, on the JDK Classic or HotSpot VMs, add the option -J-Xmx
such as -J-Xmx32m.
1 error
:brjs-core:javadoc FAILED

FAILURE: Build failed with an exception.

In this case you have two options:

  1. Try closing down the current runtime environment and re-running the command
  2. Give Java more memory when it is compiling (more information below)

Giving Java more memory for compilation

You should be able to fix it by giving Java more memory when its compiling.

We have some default values for jvmargs checked in to gradle.properties, this sets some reasonable values that we use by default and in CI. Each developer can then override these on their local machine by creating ~/.gradle/gradle.properties and adding values in there. You can also use that to enable the Gradle deamon which can speed up builds.

Try pasting the following into ~/.gradle/gradle.properties:

org.gradle.daemon=true
org.gradle.parallel=false
org.gradle.configureondemand=false
org.gradle.jvmargs=-Xms256m -Xmx512m -XX:MaxPermSize=256M

As a side note, you can also create a ~/.gradle/init.gradle to add extra build tasks/config specific to your machine. For example, I have the following in my ~/.gradle/init.gradle to; show an alert on my desktop when a build finishes; print the timestamp in the console when a build finishes; and add extra compiler args.

allprojects {
    afterEvaluate { project ->
        project.tasks.withType(Compile) {
            options.compilerArgs += ['-Xlint:-options']
        }
    }
}

rootProject {
    if (!project.name.equals("buildSrc")) {
        apply {
            plugin 'announce'
            plugin 'build-announcements'
        }
    }

}

class BuildFinishedNotifier extends BuildAdapter {
    void buildFinished(BuildResult result) {
        println "Build Finished at ${new Date()}"
    }
}
gradle.addBuildListener (new BuildFinishedNotifier())
Clone this wiki locally