Solution 1 :
It seems 8GB is really not enough for Android Studio.
I extended my swapfile from 2GB to 8GB. Now it works better. Android Studio + a few chrome tabs take all my RAM + 3GB on swap, so I think a RAM upgrade to 12GB will solve the problem.
I have 8GB of RAM and Android Studio 4.0 installed on Ubuntu 20.04. Sometimes Android Studio starts to take a lot of RAM, so that my system freezes. There are three instances of java: IDE, gradle daemon, kotlin daemon. IDE takes 3.8GB even though I’ve set max heap size to 1280MB, Gradle daemon takes more than it’s supposed to as well. How can I limit amount of RAM Android Studio can use?
I found out that it happens when I add/modify id attribute of a view. IDE process RAM consumption suddenly goes from 1GB to 5GB.
Comment posted by Bulat
@LopDev 8GB is recommended amount of RAM for AS. My project isn’t large, it has few classes.
Comment posted by Nour abo elsoud
I have 12GB of ram and 5GB of swap no chrome just android studio and I have the same issues when I am editing the layout.