This morning I have been experiencing an issue with Android Studio, whenever I open it I am getting the following error.
I also got the same problem in my case, I tried to dump memory and it is reached to 200mb and while opening the studio it is showing the continuous process, because of '.hprof' the file is loading. Finally, I removed the '.hprof' and able to run my project. The .'hprof' file removed from the directory ''
I had the same error recently (Android studio 3) even though I had 16gb Ram + I7700K CPU. I noticed that it started to appear after I disabled the Virtual Memory Ram because I needed some extra space in my SSD. so I just reactivated it and the problem was solved!
There are couple of ways to handle out of memory in Android Studio:
This happened to me when I entered /* to begin commenting out a few lines. And it happened before I could add the */ to close the comment section. Therefore, the entire second half of the file (and beyond) was being commented out. I could not go back to add the needed */ to close the comment, because the "Out of Memory" window kept popping back up before I could do so.
So I closed Android Studio, opened the same .java file in NotePad, added the needed * / a few lines below the /*, saved the file with NotePad, then reopened it again in Android Studio.
The Out of Memory problem was gone for good.
Go to /Applications and do right click on Android Studio > show package contents Then go to /Contents/bin/studio.vmoptions and change it like this:
-Xms128m
-Xmx800m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=96m
-XX:+UseCompressedOops
I was fighting with this problem today for a few hours and ended up trying File -> Invalidate Caches / Restart... and chose the Invalidate/Restart option. Seems to have fixed the Out of Memory error.
Don't know if that will work for you at a later time, but hopefully it helps.