Android Studio 編譯優化

出自Silica Library | 間奏時光
於 2022年3月28日 (一) 03:04 由 Silica對話 | 貢獻 所做的修訂 (创建页面,内容为“Category:Android == studio64.exe.vmoptions == <pre> -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.useCanon…”)
(差異) ←上個修訂 | 最新修訂 (差異) | 下個修訂→ (差異)
跳至導覽 跳至搜尋


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
    }
}