# Error: Worker exceeded memory limits. Memory used: 128 MB, Memory limit: 128 MB

- **ID:** `policy/cloudflare-worker-memory-limit-exceeded`
- **Domain:** policy
- **Category:** resource_error
- **Error Code:** `1102`
- **Verification:** ai_generated
- **Fix Rate:** 75%

## Root Cause

Cloudflare Workers have a 128 MB memory limit per request; the worker attempted to allocate more than available, causing termination.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Cloudflare Workers runtime 2024-01-01 | active | — | — |
| wrangler 3.50.0 | active | — | — |

## Workarounds

1. **Optimize memory usage by streaming large responses instead of buffering. Example: use response.body.pipeTo(writable) instead of reading entire body into memory.** (80% success)
   ```
   Optimize memory usage by streaming large responses instead of buffering. Example: use response.body.pipeTo(writable) instead of reading entire body into memory.
   ```
2. **Split the worker into multiple smaller workers that handle different parts of the request, reducing per-request memory footprint.** (70% success)
   ```
   Split the worker into multiple smaller workers that handle different parts of the request, reducing per-request memory footprint.
   ```

## Dead Ends

- **Increase the memory limit in wrangler.toml** — Cloudflare Workers memory limit is fixed at 128 MB per request for all plans; cannot be increased. (100% fail)
- **Enable auto-scaling to use more memory** — Workers don't support auto-scaling per request; each request is isolated and limited to 128 MB. (100% fail)
