1102
policy
resource_error
ai_generated
true
Error: Worker exceeded memory limits. Memory used: 128 MB, Memory limit: 128 MB
ID: policy/cloudflare-worker-memory-limit-exceeded
75%Fix Rate
90%Confidence
1Evidence
2024-01-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Cloudflare Workers runtime 2024-01-01 | active | — | — | — |
| wrangler 3.50.0 | active | — | — | — |
Root Cause
Cloudflare Workers have a 128 MB memory limit per request; the worker attempted to allocate more than available, causing termination.
generic中文
Cloudflare Workers每个请求有128 MB内存限制;worker尝试分配超过可用内存,导致终止。
Official Documentation
https://developers.cloudflare.com/workers/platform/limits/Workarounds
-
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.
Optimize memory usage by streaming large responses instead of buffering. Example: use response.body.pipeTo(writable) instead of reading entire body into memory.
-
70% success Split the worker into multiple smaller workers that handle different parts of the request, reducing per-request memory footprint.
Split the worker into multiple smaller workers that handle different parts of the request, reducing per-request memory footprint.
中文步骤
通过流式处理大响应而不是缓冲来优化内存使用。示例:使用response.body.pipeTo(writable)而不是将整个主体读入内存。
将worker拆分为多个较小的worker,处理请求的不同部分,减少每个请求的内存占用。
Dead Ends
Common approaches that don't work:
-
Increase the memory limit in wrangler.toml
100% fail
Cloudflare Workers memory limit is fixed at 128 MB per request for all plans; cannot be increased.
-
Enable auto-scaling to use more memory
100% fail
Workers don't support auto-scaling per request; each request is isolated and limited to 128 MB.