# Killed - The build process was terminated due to out of memory. Try increasing the memory limit.

- **ID:** `cicd/docker-build-oom-killed`
- **Domain:** cicd
- **Category:** resource_error
- **Error Code:** `OOM_KILLED`
- **Verification:** ai_generated
- **Fix Rate:** 78%

## Root Cause

The Docker build process exceeds the available memory on the runner or host, often due to large multi-stage builds, heavy compilation steps, or insufficient resource allocation in CI.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Docker 24.0.7 | active | — | — |
| Docker 25.0.0 | active | — | — |
| GitHub Actions runner v2.315.0 | active | — | — |

## Workarounds

1. **Increase the memory limit in the CI configuration (e.g., GitHub Actions: `options: --memory=8g` in the job definition, or Docker Compose: `mem_limit: 8g`).** (80% success)
   ```
   Increase the memory limit in the CI configuration (e.g., GitHub Actions: `options: --memory=8g` in the job definition, or Docker Compose: `mem_limit: 8g`).
   ```
2. **Optimize the Dockerfile by combining RUN commands: `RUN apt-get update && apt-get install -y package1 package2 && apt-get clean` to reduce layer count and intermediate storage.** (75% success)
   ```
   Optimize the Dockerfile by combining RUN commands: `RUN apt-get update && apt-get install -y package1 package2 && apt-get clean` to reduce layer count and intermediate storage.
   ```
3. **Use a multi-stage build with a slim base image (e.g., `FROM node:18-alpine` instead of `FROM node:18`) to reduce memory footprint during build.** (70% success)
   ```
   Use a multi-stage build with a slim base image (e.g., `FROM node:18-alpine` instead of `FROM node:18`) to reduce memory footprint during build.
   ```

## Dead Ends

- **** — Adding more RUN layers without combining them; each layer creates additional intermediate containers that increase memory pressure. (60% fail)
- **** — Removing --memory flag entirely thinking it's restrictive; the default limit might be too low, but removing it doesn't increase available memory. (50% fail)
- **** — Ignoring the error and retrying; the build will likely fail again at the same point unless memory is increased or the Dockerfile is optimized. (90% fail)
