← Guides

Android emulator slow on a 16 GB Mac

By , who makes Ramback · Updated

On a 16 GB Mac, the emulator is rarely slow on its own. Its guest RAM, Android Studio, the Gradle and Kotlin daemons and a browser add up to more than the Mac has, macOS starts swapping, and everything slows down at once. Free memory first, then fix the emulator's settings. Between builds, run ./gradlew --stop to give back what the project's Gradle and Kotlin daemons hold.

Check whether the Mac is swapping

sysctl vm.swapusage
vm.swapusage: total = 6144.00M  used = 5085.38M  free = 1058.62M  (encrypted)

Gigabytes of swap in use, or a yellow or red Memory Pressure graph in Activity Monitor, means the Mac is short on memory. The fixes below help more than any emulator flag.

Run one emulator, and stop the ones you forgot

# running emulators
adb devices

# stop one
adb -s emulator-5554 emu kill

# stop all of them
adb devices | awk '/^emulator-/{print $1}' | xargs -I{} adb -s {} emu kill

emu kill sends the emulator's own kill command, so it shuts itself down instead of being killed from outside.

Stop the Gradle daemons

Each Gradle daemon holds 1–2 GB after a build, and there's usually a Kotlin daemon next to it, which exits when the Gradle daemon does. Run ./gradlew --stop when you're done building, or see the Gradle daemon guide to stop all of them and cap their heap.

Use an arm64 image on Apple silicon

On an M-series Mac, create the device from a system image whose ABI is arm64-v8a. Those run natively through Apple's Hypervisor framework. On an Intel Mac, use x86_64 images.

Give the emulator less RAM

Phone images rarely need more than 2 GB. Lower it in Android Studio's Device Manager by editing the device, or set hw.ramSize in ~/.android/avd/<name>.avd/config.ini. For one run, start it from Terminal with a smaller size:

emulator -list-avds
emulator -avd Pixel_8_API_35 -memory 2048

emulator lives in ~/Library/Android/sdk/emulator if it isn't on your PATH. -memory accepts 1536 to 8192 MB and overrides the device's own setting. The same page now marks emulator as deprecated in favor of Google's Android CLI, which does these jobs with android emulator list, start and stop.

Keep Android Studio's own heap in check

Android Studio's own heap is set under Settings › Appearance & Behavior › System Settings › Memory Settings, which also sets the Gradle and Kotlin daemon heaps. On 16 GB, 2 to 4 GB for the IDE is plenty for most projects. More doesn't make it faster once the Mac starts swapping.