如何限制native native packager(android)(gradle)中的worker数量?

时间:2016-01-05 23:14:36

标签: android react-native circleci

使用circleci上的react.gradle构建一个android react-native项目,耗尽最大4GB内存。导致内存压力的问题之一是由打包器调整的30多个节点工作者,每个人占用近80MB。请参阅下面的示例输出。查看打包器代码,对我来说如何控制这个数字并不明显。它当然不是通过react-native bundle命令提供的选项。

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

2 个答案:

答案 0 :(得分:3)

看起来我们必须等待下一个版本。限制工作人员数量添加在this commit

答案 1 :(得分:2)

在React Native 0.22.0及更高版本中,您可以通过设置REACT_NATIVE_MAX_WORKERS环境变量来限制工作人员数量。

正如Soe Moe所说,commit增加了这种能力。

在内存较低的环境中构建时,这很有用,例如Travis或CircleCI构建容器。