Verificando autenticación…

Skip to main content

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:

  1. Optimize pipeline configuration:

    # In .gitlab-ci.yml, add memory configuration
    build:
    script:
    - export NODE_OPTIONS="--max-old-space-size=4096"
    - npm run build
  2. Reduce memory usage in build:

    • Use --max-old-space-size to increase Node.js memory limit
    • Consider incremental builds
    • Optimize dependencies and imports
  3. Runner configuration:

    • Request memory increase in shared runners
    • Consider using dedicated runners for heavy builds
  4. 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