# Stopped reason: Task stopped due to OOM (Out of Memory) kill

- **ID:** `aws/ecs-task-stopped-oom-kill`
- **Domain:** aws
- **Category:** resource_error
- **Verification:** ai_generated
- **Fix Rate:** 78%

## Root Cause

The ECS task's memory allocation was exceeded, causing the Linux kernel OOM killer to terminate the container.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| AWS CLI 2.x | active | — | — |
| ECS API 2014-11-13 | active | — | — |
| Amazon ECS Agent 1.66.0 | active | — | — |

## Workarounds

1. **Increase the task memory hard limit in the ECS task definition, e.g., set 'memory' to 2048 MiB, and ensure 'memoryReservation' is at least 512 MiB. Then redeploy the service.** (80% success)
   ```
   Increase the task memory hard limit in the ECS task definition, e.g., set 'memory' to 2048 MiB, and ensure 'memoryReservation' is at least 512 MiB. Then redeploy the service.
   ```
2. **Add memory usage monitoring via CloudWatch Container Insights: enable in ECS cluster settings, then set up a CloudWatch alarm on 'MemoryUtilized' metric. If usage spikes, consider optimizing application code to reduce memory footprint.** (85% success)
   ```
   Add memory usage monitoring via CloudWatch Container Insights: enable in ECS cluster settings, then set up a CloudWatch alarm on 'MemoryUtilized' metric. If usage spikes, consider optimizing application code to reduce memory footprint.
   ```

## Dead Ends

- **** — Increasing memory hard limit without adjusting soft limit or task memory reservation can still cause OOM if the container exceeds the hard limit. (65% fail)
- **** — Rebuilding the container with a different base image without monitoring memory usage doesn't address the root cause of memory leak or high consumption. (50% fail)
