I was building hibernate-core in Eclipse using Gradle, it always hang there for 5 minute executing :hibernate-core:findbugsTest and report there is a problem with the heap space.

I tried add -XX:MaxHeapSize=1000m to Preferences - Gradle - JVM arguments but didn't work. I can see two java.exe process in task manager, one process has -XX:MaxHeapSize=1000m in the command line column, obviously this is our Gradle process, but it does not consume CPU, the other one keeps consuming 25% CPU and very little memory, but the memory increase very quickly after several minutes and then fails.

One of the solutions I found is add this to build.gradle

    tasks.withType(FindBugs) {
        maxHeapSize = 512m'

This time the build will throws errors after 9 minutes.

Then I changes the maxHeapSize to 1000m

    tasks.withType(FindBugs) {
        maxHeapSize = '1000m'

This time it runs for 18 minutes and failed, looks like there are some kind of connection between the maxHeapSize and build running time.

I have to disable findbugs plugin

ext.useFindBugs = false

This time the test fails

Execution failed for task ':hibernate-core:test'.

Here is one of the errors

Could not reserve enough space for 2097152KB object heap

This is 2GB of memory, the physical memory on my machine is 2GB only. If you want to build hibernate, you should have bigger enough memory.