Building an android react-native project using react.gradle on circleci runs out of the max 4GB memory. One of the issues leading to the memory pressure is the 30+ node workers spinned up by the packager each taking up nearly 80MB. See below for the sample output. Looking through the packager code it's not obvious to me how to control this number. It certainly not an option available through the react-native bundle
command.
PID RSS %CPU COMMAND
14799 60988 5.0 /home/ubuntu/nvm/versions/node/v5.0.0/bin/node /home/ubuntu/mobile_android_circleci/mobile/node_modules/react-native/node_modules/worker-farm/lib/child/index.js
14804 58696 4.2 /home/ubuntu/nvm/versions/node/v5.0.0/bin/node /home/ubuntu/mobile_android_circleci/mobile/node_modules/react-native/node_modules/worker-farm/lib/child/index.js
14709 58036 4.1 /home/ubuntu/nvm/versions/node/v5.0.0/bin/node /home/ubuntu/mobile_android_circleci/mobile/node_modules/react-native/node_modules/worker-farm/lib/child/index.js
14814 57832 4.4 /home/ubuntu/nvm/versions/node/v5.0.0/bin/node /home/ubuntu/mobile_android_circleci/mobile/node_modules/react-native/node_modules/worker-farm/lib/child/index.js
14764 57792 4.3 /home/ubuntu/nvm/versions/node/v5.0.0/bin/node /home/ubuntu/mobile_android_circleci/mobile/node_modules/react-native/node_modules/worker-farm/lib/child/index.js
14789 57720 4.2 /home/ubuntu/nvm/versions/node/v5.0.0/bin/node /home/ubuntu/mobile_android_circleci/mobile/node_modules/react-native/node_modules/worker-farm/lib/child/index.js
14734 57700 4.2 /home/ubuntu/nvm/versions/node/v5.0.0/bin/node /home/ubuntu/mobile_android_circleci/mobile/node_modules/react-native/node_modules/worker-farm/lib/child/index.js
14688 57576 4.2 /home/ubuntu/nvm/versions/node/v5.0.0/bin/node /home/ubuntu/mobile_android_circleci/mobile/node_modules/react-native/node_modules/worker-farm/lib/child/index.js
14809 57544 4.2 /home/ubuntu/nvm/versions/node/v5.0.0/bin/node /home/ubuntu/mobile_android_circleci/mobile/node_modules/react-native/node_modules/worker-farm/lib/child/index.js
14724 57504 4.1 /home/ubuntu/nvm/versions/node/v5.0.0/bin/node /home/ubuntu/mobile_android_circleci/mobile/node_modules/react-native/node_modules/worker-farm/lib/child/index.js
14719 57284 4.0 /home/ubuntu/nvm/versions/node/v5.0.0/bin/node /home/ubuntu/mobile_android_circleci/mobile/node_modules/react-native/node_modules/worker-farm/lib/child/index.js
14694 57260 4.0 /home/ubuntu/nvm/versions/node/v5.0.0/bin/node /home/ubuntu/mobile_android_circleci/mobile/node_modules/react-native/node_modules/worker-farm/lib/child/index.js
...
+ MANY MORE ROWS
Looks like we have to wait for next release. The limit number of workers is added in this commit.
In React Native 0.22.0 and later you can limit the number of workers by setting the REACT_NATIVE_MAX_WORKERS
environment variable.
As Soe Moe mentioned, this commit added the ability.
This is useful when building in a somewhat low-memory environment, such as a Travis or CircleCI build container.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With