首先打开Android studio包,进入MacOs,运行studio,可以出现运行信息
2019-12-19 09:35:15.151 studio[30474:1303629] allVms required 1.8*,1.8+
2019-12-19 09:35:15.154 studio[30474:1303633] fullFileName is: /Applications/Android Studio.app/Contents/bin/studio.vmoptions
2019-12-19 09:35:15.154 studio[30474:1303633] fullFileName exists: /Applications/Android Studio.app/Contents/bin/studio.vmoptions
2019-12-19 09:35:15.154 studio[30474:1303633] Value of STUDIO_VM_OPTIONS is (null)
2019-12-19 09:35:15.154 studio[30474:1303633] Processing VMOptions file at /Applications/Android Studio.app/Contents/bin/studio.vmoptions
2019-12-19 09:35:15.154 studio[30474:1303633] Done
2019-12-19 09:35:15.154 studio[30474:1303633] Processing VMOptions file at /Users/【youUserName】/Library/Preferences/AndroidStudio3.5/studio.vmoptions
2019-12-19 09:35:15.155 studio[30474:1303633] Done
2019-12-19 09:35:15.155 studio[30474:1303633] Processing VMOptions file at
2019-12-19 09:35:15.156 studio[30474:1303633] No content found
Error occurred during initialization of VM //II 错误信息
Initial heap size set to a larger value than the maximum heap size
II、 VM初始化期间发生错误,初始堆大小设置为大于最大堆大小的值
于是我们只要找到初始化堆大小的位置和最大堆大小的位置,将这两个值中的一个调整一下就好了。而VM的相关配置信息在VMOptions对应的文件中。从运行信息中可以看到有两个文件分别是:
/Applications/Android Studio.app/Contents/bin/studio.vmoptions
和
/Users/【youUserName】/Library/Preferences/AndroidStudio3.5/studio.vmoptions
由于不知道运行的是哪个配置文件,所以最好就两个都改,其中:
-Xms //初始化堆大小
-Xmx //最大堆大小
只要让-Xms
的值小于-Xmx
的值就可以了。