How To Reconfigure HAXM Allocated Ram On A Mac or PC
Sometimes you might need to reconfigure HAXM, the tool that allows you to run the faster x86 Android emulator on your computer.
Firstly, HAXM is for Intel CPU’s only, so if you dont have an Intel CPU, you need instead to use the ARM system image and the rest of this guide will not apply to you.
When Android Studio is installed, it automatically installs/starts HAXM, but sometimes it can allocate the wrong amount of memory.
How do we re-configure? By running the HAXM installer again and specifying new numbers.
Here is how to do it. Firstly, you need to know the location of where Android Studio has loaded the Android SDK on your system.
Start Android Studio, and from the main menu choose Configure -> Project Defaults -> Project Structure.
You should see a screen like this.
You need to navigate to the folder showing in the Android SDK location. For me, on a mac its shown on the image above.
On a Mac Open finder, then choose Go -> Go to Folder -> and paste the URL from Android studio and click Go to open that folder.
Windows users, navigate to the folder. I found this post about how you can paste in a path and go there directly. If you have some tips on how to do it easier on a Windows machine, please leave a comment and I will update this post.
Once you have navigated to the folder you should see a structure like this.
Notice how there was an extras folder, then intel, then Hardware_Accelerated_Execution_Manager. Navigate to the HAXM folder.
Make sure any AVD’s and Android studio are not running before proceeding.
You then need to execute the HAXM installer that is showing in this folder (again, I am showing the Mac screen, but the PC screen will have a HAXM installer as well).
When it starts you should see this message
This is telling you that HAXM is going to be re-installed. Click OK and Continue
You should see this screen.
On this screen you want to change the allocation of ram for your computer. On my computer I have 32GB of ram, so I can allocate 2048 Mb (2GB). But you probably need 8GB or more of ram to be able to allocate 2GB, so experiment to get the right value.
Note that the Nexus 5 image needs 1536Mb (1.5GB), so if you had an error like this…
emulator: WARNING: Requested RAM size of 1536MB is too large for your environment, and is reduced to 864MB.
emulator: device fd:596
That is telling you that its needs HAXM to be 1536Mb or more to work. On an 8GB system choose 2GB (2048Mb).
If you have less ram or cannot get it working, use the Nexus 4 image and choose a smaller amount.
Once you have chosen the ram, proceed to finishing off the HAXM installation.