P
P
prosto_anton2016-06-05 21:16:29
Android
prosto_anton, 2016-06-05 21:16:29

How to reduce memory consumption when building in Android Studio?

The essence of the problem is that on my laptop all 4GB of RAM and it will not be possible to buy in addition (the laptop is old).
Therefore, you have to shaman with the gradle settings. In principle, I have about 2.5 GB free, I don’t want to use swap.
Tried setting following build settings in studio in Gradle-Android Compiler dialog:
--parallel --max-workers=2 --no-rebuild -Dorg.gradle.jvmargs=-Xmx1536m
a74f4b83646a4afa8a409add6658c829.png
Also tried setting settings in $HOME_DIRECTORY/.gradle/ file gradle.properties:
org.gradle.parallel=false
org.gradle.daemon=true
org.gradle.jvmargs=-Xms1024m -Xmx1024m -XX:MaxPermSize=512m
org.gradle.configureondemand=false
org.gradle.workers.max=1
I also tried to set the settings in the gradle.properties file in the project itself:
org.gradle.jvmargs=-Xms1024m -Xmx1024m -XX:MaxPermSize=512m I
also tried to set environment variables:
GRADLE_OPTS=-Xmx1024m In
no case did it help, the process tried to devour all available system resources and even more.
Question:
where exactly should I change the project settings?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
prosto_anton, 2016-06-05
@prosto_anton

In general, if someone is interested in my experience.
We cut the memory for the gradle daemon, since it does not do too much, but by default it eats decently.
The main role in the assembly process is played by packaging, although it may not have been correctly named. Here, memory consumption can be adjusted as follows:
android {
dexOptions {
maxProcessCount 1
javaMaxHeapSize '1200m'
}
}
The figure of 1200MB is reached empirically, will depend on the application.
I also trimmed the idea resources, she was not offended:
-Xms128m
-Xmx128m
-XX:ReservedCodeCacheSize=32m

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question