Android emulator slow on a 16 GB Mac
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.
Check whether it's memory
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 killemu kill tells the emulator itself to shut down, instead of killing its process from outside.
Stop the Gradle daemons
Each Gradle daemon can hold 2 GB or more after a build, and there's usually a Kotlin daemon next to it. 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. Google's newer Android CLI does the same jobs with android emulator list, start and stop.
Leave Android Studio room
Android Studio's own heap is set under Settings › Appearance & Behavior › System Settings › Memory Settings. On 16 GB, 2 to 4 GB is plenty for most projects. More doesn't make it faster once the Mac starts swapping.