Gradle 1.7 + Oracle JDK7u40 + Linux 32bit == Could not reserve enough space for object heap


(Darryl Miles) #1

Gradle 1.7 + Oracle JDK7u40 + Linux 32bit == Could not reserve enough space for object heap.

How do I tweak the daemon opts -XX:MaxPermSize=256m to make it 128m for 32bit.

I tried setting JAVA_OPTS to see if gradle would pickup the setting to use from this (maybe it should appear to daemon opts the $JAVA_OPTS to allow this override).

At 256m 0% of JVM processes will start. At 160m 50% of JVM processes will start, I guess due to mmap() layout randomization and the luck of the draw as to how many MBs were lost. At 145m 85% of JVM processes will start. At 128m 100% of JVM processes will start.

Test is simply to run: java -XX:MaxPermSize=256m You should get the java help message, not the error as per the thread subject.

When I say processes start, I mean the daemon mode and background forking that seems to create additional JVMs on demand.

I think this is a bug as the value should be tweaked to be higher for 64bit JVM and lower for 32bit JVM mainly due to memory pointer size losage that increases runtime expected available memory on a 64bit host system.

This increase is generally not a 200% as my request here indicates, but I suspect that 256m is overkill and you can probably fix the same issue using this high (256m) setting intends to resolve at 192m even on 64bit system. But no one cares on 64bit using too high a setting since usually there is no pressure to get everything into 4Gb address space and more system memory is usually around than 32bit systems.

So ideally gradle should detect if the runtime JVM is 32bit and use 128m and if 64bit use 256m.

An example of the problem with --debug output snipped up to show only relevant parts, the problem affects BOTH the daemon startup and the regular process JVM spawning:

[DEBUG] [org.gradle.process.internal.DefaultExecHandle] Environment for process ‘Gradle Worker 4’ … /opt/jdk1.7.0_40/bin/java … -XX:MaxPermSize=256m … … [QUIET] [system.out] Could not reserve enough space for object heap

I tried setting “export GRADLE_OPTS=-XX:MaxPermSize=128m” to make a difference.


(Darryl Miles) #2

The workaround is to use Linux 64bit system (with same version of JDK 7u40 but for 64bit Linux)