——-EDIT——–
Android Studio 2.0 and above, you can create/edit this file by accessing “Edit Custom VM Options” from the Help menu.
——-ORIGINAL ANSWER——–
Open file located at
/Applications/Android\ Studio.app/Contents/bin/studio.vmoptions
Change the content to
-Xms128m
-Xmx4096m
-XX:MaxPermSize=1024m
-XX:ReservedCodeCacheSize=200m
-XX:+UseCompressedOops
Xmx
specifies the maximum memory allocation pool for a Java Virtual Machine (JVM), while Xms
specifies the initial memory allocation pool. Your JVM will be started with Xms
amount of memory and will be able to use a maximum of Xmx
amount of memory.
Save the studio.vmoptions
file and restart Android Studio.
Note:
If you changed the heap size for the IDE, you must restart Android Studio before the new memory settings are applied. (source)