Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Out of Memory

Tags:

This morning I have been experiencing an issue with Android Studio, whenever I open it I am getting the following error.Android Studios Out of Memory error

I have tried removing Android Studio and getting a clean install. Removing all the preference folders. Removing and re-downloading my project's repository. Creating a new project. All of these still end with this error showing up. No mater how high I increase the memory it is still getting this issue.

I have checked the Activity Monitor and it is actually only using 524mb of memory. Does anyone have any suggestions?

The next thing I'm going to try is using an older version of Android studios. Apart from that I'm not sure what else to do beside a clean install of the OS and hope for the best.

UPDATE: Couldn't work out a way of fixing this, and had to perform a clean reinstall of OSX.

like image 356
Cassie Avatar asked Nov 08 '13 01:11

Cassie


People also ask

How do I fix out of memory error in Android Studio?

If you haven't yet encountered an OOM in your Android application, you will in the near future. Memory leaks cause the OutOfMemoryError in Android. To eliminate the OutOfMemoryError, you must first eliminate memory leaks from your Android application. The Error!

How does Android handle out of memory?

Check that the image size is smaller than the available memory before attempting to load it. So the most efficient way to handle OutOfMemoryException is to architecture your application in such a way that it never attempts to load lots of data into memory in order to avoid the exception.

What causes memory leaks in Android?

Memory leaks occur when an application allocates memory for an object, but then fails to release the memory when the object is no longer being used. Over time, leaked memory accumulates and results in poor app performance and even crashes.


2 Answers

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.

like image 57
justinkmunger Avatar answered Oct 14 '22 20:10

justinkmunger


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

like image 34
Fernando Gallego Avatar answered Oct 14 '22 20:10

Fernando Gallego