Go to Help ->Edit Custom VM Options, and chnge this 4 setting. After that close your Android Studio. This settings are for 8gb of ram pc.
# custom Android Studio VM options, see https://developer.android.com/studio/intro/studio-config.html
-Xmx2g
-Xms1G
-XX:MaxPermSize=1G
-XX:ReservedCodeCacheSize=512m
# custom Android Studio VM options, see https://developer.android.com/studio/intro/studio-config.html
-Xmx2g
-Xms1G
-XX:MaxPermSize=1G
-XX:ReservedCodeCacheSize=512m