I just upgraded to Android Studio 2.2 and I can no longer build my project because the Gradle build always fails with multiple java.lang.OutOfMemoryError: unable to create new native thread
From my research, it seems this could have more to do with my operating system (OSX El Capitan) than with Gradle itself. However, I have attempted several workarounds with no success.
My studio.vmoptions file looks like this:
# custom Android Studio VM options, see http://tools.android.com/tech-docs/configuration
-Xms128m
-Xmx750m
-XX:MaxPermSize=512m
-XX:ReservedCodeCacheSize=96m
-XX:+UseCompressedOops
-XX:+HeapDumpOnOutOfMemoryError
ulimit -a
gives me the following:
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 256
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 709
virtual memory (kbytes, -v) unlimited
I've tried increasing my max user processes to no avail. Is anyone else having this issue? My current JDK is 1.8.0_102
OutOfMemoryError: Unable to create new native thread means that the Java application has hit the limit of how many Threads it can launch.
Each JVM server can have a maximum of 256 threads to run Java applications.
"Native threads" refers to a in which the Java virtual machine creates and manages Java threads using the operating system threads library - named libthread on UnixWare - and each Java thread is mapped to one threads library thread.
I have the same issue with my project which can be built without problem before upgrading.
Switched back to gradle 2.1.3 from 2.2.0 fixed the problem.
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With