## TL;DR
MEMORY_LIMIT_EXCEEDED on an Apify actor means the crawl held too much in memory at once, usually by accumulating every page's HTML or screenshot before writing results. Stream results to the dataset as you go and cap concurrency, and the same actor will finish the same crawl in the same memory.

## The error
```text
Run failed: MEMORY_LIMIT_EXCEEDED
Memory usage exceeded the limit of 4096 MB.
The actor was terminated to protect the platform.
```

## Fix it
1. Open the run log and find where memory climbs. A steady climb that never drops means accumulation; a sudden spike means one huge page or asset.
   Expected: Expected: the log's memory graph shows the pattern, which tells you which fix to apply.
2. Change the actor to push each result to the dataset immediately after extraction instead of appending to an in-memory list.
   Expected: Expected: memory stays flat across the run instead of climbing with page count.
3. Lower maxConcurrency and set a per-page navigation timeout so slow pages cannot pile up in parallel.
   Expected: Expected: peak memory drops roughly in proportion to the concurrency reduction.
4. If single pages still blow memory, skip downloading heavy assets (images, video) with request interception and cap the HTML stored per page.
   Expected: Expected: the run completes within the memory limit on the same URL list.

## When to use
- Your bulk news crawl actor dies partway with MEMORY_LIMIT_EXCEEDED.
- You need to tell result accumulation apart from a single pathological page.
- You run large scheduled crawls on fixed-memory actor plans.

## When not to use
- The error is a timeout, not memory - that is a different resource limit.
- The actor runs fine locally but fails on the platform - check the platform's memory setting first.
- You genuinely need more memory for the workload - then raise the plan limit instead of optimizing.

## Why it happens
Apify kills actors that exceed their memory allocation. Crawlers most often exceed it by keeping every fetched page, screenshot, or parsed DOM in a list until the end of the run. Memory grows linearly with pages crawled until the platform terminates the process.

## Variant phrasings
### apify MEMORY_LIMIT_EXCEEDED actor
Same failure and fix; some searchers phrase the query this way.
### apify actor out of memory bulk crawl fix
Same failure and fix; some searchers phrase the query this way.

## Edge cases
- Screenshots are the usual hidden cost; one full-page screenshot per article on a 10k-page crawl is gigabytes.
- Cheerio or JSDOM instances held across pages leak; create and discard the parser per page.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_W8fh7mWiQkUogZOiF3OZdQ
