Android Studio 编译优化

来自Silica Library | 間奏時光
跳到导航 跳到搜索


studio64.exe.vmoptions

-server
-Xms4g
-Xmx4g
-XX:+BackgroundCompilation
-XX:+AggressiveOpts
-XX:+UseNUMA
-XX:+UseParallelOldGC
-XX:+UseParallelGC
-XX:-UseConcMarkSweepGC
-XX:-UseG1GC
-XX:ParallelGCThreads=48
-XX:CICompilerCount=48
-XX:SurvivorRatio=28
-XX:TargetSurvivorRatio=95
-XX:MaxTenuringThreshold=15
-XX:MaxGCPauseMillis=500
-XX:ReservedCodeCacheSize=2g
-XX:SoftRefLRUPolicyMSPerMB=50
-XX:CICompilerCount=2
-Dsun.io.useCanonCaches=false
-Djdk.http.auth.tunneling.disabledSchemes=""
-Djdk.attach.allowAttachSelf=true
-Djdk.module.illegalAccess.silent=true
-Dkotlinx.coroutines.debug=off
-Djna.nosys=true
-Djna.boot.library.path=
-Didea.vendor.name=Google

gradle.properties

org.gradle.configureondemand=true
org.gradle.caching=true
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.parallel.threads=48
org.gradle.jvmargs=-server -XX\:+BackgroundCompilation -XX\:+AggressiveOpts -XX\:+AggressiveHeap -XX\:+UseNUMA -XX\:+UseParallelOldGC -XX\:+UseParallelGC -XX\:-UseConcMarkSweepGC -XX\:ParallelGCThreads\=64 -XX\:CICompilerCount\=64 -XX\:SurvivorRatio\=28 -XX\:TargetSurvivorRatio\=95 -XX\:MaxTenuringThreshold\=15 -XX\:MaxGCPauseMillis\=500 -Xms4g -Xmx4g -XX\:-HeapDumpOnOutOfMemoryError -Dfile.encoding\=UTF-8
org.gradle.workers.max=48
kotlin.incremental=true
kotlin.caching.enabled=true

Android Studio - Build - Compiler - Command-line Options

--parallel --daemon --build-cache --max-workers=128 -Dorg.gradle.jvmargs="-server -XX\:+BackgroundCompilation -XX\:+AggressiveOpts -XX\:+AggressiveHeap -XX\:+UseNUMA -XX\:+UseParallelOldGC -XX\:+UseParallelGC -XX\:-UseConcMarkSweepGC -XX\:ParallelGCThreads\=64 -XX\:CICompilerCount\=64 -XX\:SurvivorRatio\=28 -XX\:TargetSurvivorRatio\=95 -XX\:MaxTenuringThreshold\=15 -XX\:MaxGCPauseMillis\=500 -Xms4g -Xmx4g -XX\:-HeapDumpOnOutOfMemoryError -Dfile.encoding\=UTF-8"
Open: Compile independent modules in parallel (may require larger heap size)
Close: Make project automatically (only works while not running / debugging)
Close: Sync project with Gradle before building, if needed

module build.gradle

android {
    dexOptions {
        incremental true
        javaMaxHeapSize "16g"
        jumboMode = true
        preDexLibraries = true
        threadCount = 48
    }
}