Article structure:
- Early attention
- Optimization method
Preliminary Note:
Pre-configuration (with or without matching)
View execution memory and allocated memory
Thumbnail (for easy viewing)
If you can't view it, please set it according to the picture below
Notice:
No matter how to optimize the compilation speed, we need to restart As to take effect
Optimization method
Method 1 : Memory allocation (the size of the internal allocation depends on your computer configuration, the general computer configuration can be set as follows)
step:
- Modify the memory allocation of AndroidStudio
- Modify the data in the studio64.exe.vmoptions file (friendly reminder: you can rename the file suffix to meet the needs of modification, remember to change it back after modification!)
-Xms1024m //JVM启动的起始堆内存
-Xmx4096m //AndroidStudio能使用的最大heap内存
-XX:MaxPermSize=1024m //最大的Permanent generation大小。存放的事类本身(不是对象),以及方法,一些固定的字符串等等。
-XX:ReservedCodeCacheSize=512m //设置JIT java compiler在compile的时候的最大代码缓存
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=300
This is the modified parameter map:
Modified parameter code:
-Xms1024m
-Xmx2048m
-XX:ReservedCodeCacheSize=1024m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djna.nosys=true
-Djna.boot.library.path=
-da
If you modify it according to the above picture and the compilation speed does not improve after restarting As, then please follow the picture below to see if you do this!
User directory, view the corresponding version of As
Check if there is this file, if so, modify it~