Android studio 2.0 Preview 8 with gradle plugin 2.0.0-alhpa8, warning of memory preservation despite heap size up to 4 GB

I just updated the version for Android Studio version 2.0 Preview 8 and gradle 2.0.0-alpha8. I noticed that there is now a warning if the heap of space is not large enough to be deleted.

As stated on the corresponding page ( http://tools.android.com/recent )

In 2.0.0-alpha8, we added some automatic diagnostics for this: if the build process is too small, we return to turning off the memory from the memory and issue a build warning explaining how to raise the gradle daemon. (We are also working on some additional next build after alpha8.)

When I started building my project, I got the following error:

To run dex in the process, a large heap is required for the gradle daemon. It currently has 3641 MB. For faster assembly, increase the maximum heap size for the gradle daemon to more than 4 g, as indicated in dexOptions.javaMaxHeapSize. To do this, set org.gradle.jvmargs = -Xmx4g as specified in dexOptions.javaMaxHeapSize in the gradle.properties project. For more information see https://docs.gradle.org/current/userguide/build_environment.html

In fact, I get a lot of them in a row. Which surprises me, because this is what I see in my gradle.properties file (in my project home directory)

ANDROID_BUILD_TARGET_SDK_VERSION=23 ANDROID_BUILD_TOOLS_VERSION=23 ANDROID_BUILD_SDK_VERSION=23 ANDROID_BUILD_MIN_SDK_VERSION=16 org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 

also, in build.gradle of my main module, I put

 android { dexOptions { incremental true javaMaxHeapSize "4g" } } 

so I don’t understand where the builder / dexer / compiler gets this value 3641MB.

Lines are very slow

I turned off instant start, and now everything is faster. 48-50 seconds to build. I still get the same error, but only once and not many times in a row.

I am on Linux, my ulimit -a looks like this:

 core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 31483 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 31483 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited 

Also, this is my studio.vmoptions file: https://gist.github.com/MarKco/1ae7918daf867a378a2f I assume it is unedited. I may have the usual, but I do not know where this may be.

+6
source share
1 answer

I decided that it is so. The last change I made before I posted the question was as follows:

I had

 ANDROID_BUILD_TARGET_SDK_VERSION=22 ANDROID_BUILD_TOOLS_VERSION=22 ANDROID_BUILD_SDK_VERSION=22 ANDROID_BUILD_MIN_SDK_VERSION=16 org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 

and I changed it to

 ANDROID_BUILD_TARGET_SDK_VERSION=23 ANDROID_BUILD_TOOLS_VERSION=23 ANDROID_BUILD_SDK_VERSION=23 ANDROID_BUILD_MIN_SDK_VERSION=16 org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 

I do not know why it did not change automatically, since I used 23 as the target version for a long time. In any case, after I changed from 22 to 23, I did not have a good build, but this seems to be due to the fact that gradle synchronization is still running in the background. I killed all gradle projects, saved version 23 instead of 22, turned off instant start and performed a new synchronization. At first, I continued to use "To start dex in a process, the gradle daemon needs a large heap." error, only once and does not repeat, as it was before. But after the build, I saw the build time go down until I got the 10 second build. I think it decided. Hopefully at least.

PS In the end, I changed MaxPermSize according to what Henry said, now my configuration

 ANDROID_BUILD_TARGET_SDK_VERSION=23 ANDROID_BUILD_TOOLS_VERSION=23 ANDROID_BUILD_SDK_VERSION=23 ANDROID_BUILD_MIN_SDK_VERSION=16 org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 
+3
source

All Articles