r/reactnative • u/MaybePoem • 2d ago
Help Developing on Mac, running android simulator is maxing my RAM
Hi,
I am developing a react native expo app on Macbook Air M4 with 16GB of RAM.
And whenever I am running an android simulator, either for actual build or for simulator its maxing my RAM, especially during the startup. After that it's sitting quite ok at about 5GB of RAM (which is still A LOT). But during the startup it can reach to 16GB of RAM.
I am using Android Studio built in Pixel 10 emulator.
Is there any alternative or something I am doing wrong here?
3
Upvotes
5
u/XyrelTzy 2d ago
use pixel 6 or 7. In app development android emulator, jvm, java is the one consume more ram.
3
u/LovinglyLate 2d ago
I had the same issue, I ended up using https://github.com/kdbhalala/avdslim and it made it a lot more usable
2
u/rsajdok 2d ago
Use for tests android phone
2
u/dawedev 2d ago
If the 16GB spike is at startup, check that Quick Boot is on in the AVD settings so it resumes from a snapshot instead of cold booting every time. It also helps to let the emulator finish booting before you kick off the first Gradle build, otherwise both peak at the same moment.
1
u/MobileXapps 2d ago
Close Android Studio while the emulator runs and start it from the terminal with
emulator -avd <name>. The IDE itself takes a few GB on top of Gradle and the emulator.In the AVD settings you can also lower the RAM and pick an older Pixel image without Play Store. And if you have any Android phone lying around, plug it in over USB, it costs your Mac basically nothing.
1
u/codariadev 2d ago
That startup spike is usually two things at once: the emulator cold booting and the first Gradle build. A few things that helped me on a 16 GB machine:
emulator -list-avdsand thenemulator -avd <name>(it's in~/Library/Android/sdk/emulator).android/gradle.properties(org.gradle.jvmargs=-Xmx2048m ...) if you're doing local builds, and avoid rebuilding when you don't need to. With a dev build installed,npx expo startonly runs Metro, the native build isn't repeated.If it's still painful, a cheap physical Android phone over USB is honestly the lightest option, zero emulator overhead.
1
u/darrenferneyhough 1d ago
one thing not mentioned, the gradle daemon stays in memory for up to 3 hours after a build by default. running ./gradlew --stop in the android folder once the app is installed gives that back, or do the dev build on eas so gradle never runs on your mac at all
1
u/zzoa7922 1d ago
Not on a Mac (Windows, and a slow PC), but I hit the same wall and stopped using the emulator for daily work. I test my Expo apps on a real Android phone over USB with adb instead, and it's way lighter on the machine. You also see real performance, which the emulator hides.
1
u/devsav_codes 1d ago
Had the same issue on an M-series Mac. A few things that helped me:
- In Device Manager, edit the AVD and drop RAM to 2 GB. It doesn't need more for an Expo app.
- Use a lighter system image (an older API level, no Play Store image unless you need it).
- Start the emulator from the terminal (`emulator -avd <name>`) and keep Android Studio closed. Studio itself eats a few GB.
- Turn on Quick Boot so it isn't cold booting every time.
Honestly though, the biggest win was testing on a real Android phone over USB or wireless debugging. Almost zero RAM on the Mac and it's closer to what users see.
1
u/Russel-D-Souza 1d ago
Others covered the emulator side, so on the build side: if the spike is mostly Gradle, try org.gradle.workers.max=2 and org.gradle.parallel=false in gradle.properties. The build gets slower, but fewer things peak at once. With Expo prebuild the android folder can be regenerated, so set it through a config plugin if you want it to stick.
Also, you only need a native rebuild when native code or config changes. For JS changes, keep the dev build installed and just run npx expo start.