I`m running a legacy react native app (0.68.5), with a MacBook Pro (m2, 16GB of ram), and i keep getting:
Reached heap limit Allocation failed - JavaScript heap out of memory
Some time the app runs for about 15 - 30 minutes then crashes.
I`m running with Xcode (no idea if changes from terminal yarn react-native run-ios
)
OBS: the app runs with metro bundler under the hood
The JavaScript heap size (by default ~1.5GB–2GB) is being exceeded.
The app runs for a while (15–30 min) — suggests a memory leak or gradual bloat.
Immediate Fix (Heap Size) :- Try increasing the Node.js heap size. You can do this by explicitly setting the NODE_OPTIONS env variable:
Run Metro manually with increased memory:
export NODE_OPTIONS=--max_old_space_size=4096
yarn start