You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/workers/platform/limits.mdx
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -148,17 +148,19 @@ Routes in fail closed mode will display a Cloudflare `1027` error page to visito
148
148
149
149
## Memory
150
150
151
-
Only one Workers instance runs on each of the many global Cloudflare global network servers. Each Workers instance can consume up to 128 MB of memory. Use [global variables](/workers/runtime-apis/web-standards/) to persist data between requests on individual nodes. Note however, that nodes are occasionally evicted from memory.
151
+
Each [isolate](/workers/reference/how-workers-works/#isolates) your Worker's code runs in can consume up to 128 MB of memory. This includes both memory used by the JavaScript heap, and memory explicitly allocated in [WebAssembly](/workers/runtime-apis/webassembly/). Note that this limit is per-isolate, not per-invocation of your Worker. A single isolate can handle many concurrent requests.
152
152
153
-
If a Worker processes a request that pushes the Worker over the 128 MB limit, the Cloudflare Workers runtime may cancel one or more requests. To view these errors, as well as CPU limit overages:
153
+
If at any point in time an isolate running your Worker uses more than 128 MB of memory, rather than immediately failing with an error, the Workers runtime will attempt to allow in-flight requests to that isolate to complete, and will create a new isolate for your Worker. In this process, the Workers runtime still may cancel one or more incoming requests, but ensures that if your Worker exceeds memory limits, it is automatically restarted as gracefully as possible.
154
+
155
+
To view out-of-memory errors (OOM), as well as CPU limit overages:
154
156
155
157
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com) and select your account.
156
158
2. Select **Workers & Pages** and in **Overview**, select the Worker you would like to investigate.
157
159
3. Under **Metrics**, select **Errors** > **Invocation Statuses** and examine **Exceeded Memory**.
158
160
159
-
Use the [TransformStream API](/workers/runtime-apis/streams/transformstream/) to stream responses if you are concerned about memory usage. This avoids loading an entire response into memory.
161
+
To avoid exceeding memory limits, where possible you should avoid buffering large objects or responses in memory, and instead use streaming APIs such as [`TransformStream`](/workers/runtime-apis/streams/transformstream/)or [`node:stream`](/workers/runtime-apis/nodejs/streams/)to stream responses. Manipulating streams allows you to avoid buffering entire responses in memory.
160
162
161
-
Using DevTools locally can help identify memory leaks in your code. See the [memory profiling with DevTools documentation](/workers/observability/dev-tools/memory-usage/) to learn more.
163
+
You can also use Chrome DevTools in local development to identify memory leaks in your code. See the [memory profiling with DevTools documentation](/workers/observability/dev-tools/memory-usage/) to learn more.
162
164
163
165
---
164
166
@@ -334,4 +336,4 @@ Review other developer platform resource limits.
0 commit comments