OOMKilled in GitLab CI/CD - React build fails due to memory
Common Problems or Queries
- OOMKilled error when compiling React projects in GitLab CI/CD
- Build fails due to lack of memory during compilation
- Pipeline interrupted with insufficient memory error
- Multiple projects affected by the same memory problem
Solution
The OOMKilled (Out Of Memory Killed) error occurs when the build process consumes more memory than available in the GitLab CI/CD runner. This problem especially affects React builds that require more resources during compilation.
Steps to resolve:
-
Optimize pipeline configuration:
# In .gitlab-ci.yml, add memory configurationbuild:script:- export NODE_OPTIONS="--max-old-space-size=4096"- npm run build -
Reduce memory usage in build:
- Use
--max-old-space-sizeto increase Node.js memory limit - Consider incremental builds
- Optimize dependencies and imports
- Use
-
Runner configuration:
- Request memory increase in shared runners
- Consider using dedicated runners for heavy builds
-
Optimization alternatives:
- Split the build into smaller stages
- Use dependency cache to reduce build time
- Implement parallel builds if possible
Responsible team: ANDES Entrega Typical environment: PROD Reference ticket: ANDES-503