<!-- llms-explorer concept facts · https://llms-explorer.com/tree/memory-limits-and-allowdiskuse/ · pack 2026-10-15 · ~2436 tokens -->

# Memory Limits and allowDiskUse

> Depth-first rabbithole dossier for Memory Limits and allowDiskUse; source-anchored research pack.

Parent: [MongoDB Aggregation Pipeline](https://llms-explorer.com/tree/mongodb-aggregation-pipeline/) · 3 facets · 19 facts · page: https://llms-explorer.com/tree/memory-limits-and-allowdiskuse/

## How it works

- [low] A fix for `$graphLookup` spilling to disk when frontier and visited set sizes exceed maximum memory usage is targeted for version 8.2.0-rc0. (verified as of 2026-10-15) Sources: https://jira.mongodb.org/browse/SERVER-23980 — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#troubleshooting`

## Problems, failure modes and limitations

- [high] The `$graphLookup` stage has a strict 100 MB memory limit and ignores the `allowDiskUse` parameter, though it may automatically write temporary files to disk if memory consumption exceeds 100 MB. (verified as of 2026-10-15) Sources: https://www.mongodb.com/docs/languages/python/pymongo-driver/current/aggregation.md, https://www.mongodb.com/docs/drivers/java/sync/current/aggregation.md, https://www.mongodb.com/docs/manual/reference/operator/aggregation/graphLookup.md, https://mongoosejs.com/docs/api/aggregate.html — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#core`
- [high] MongoDB pipeline stages have a default memory limit of 100 megabytes, and stages requiring more memory write temporary files to disk by default. Sources: https://www.mongodb.com/docs/manual/reference/command/aggregate.md, https://www.mongodb.com/docs/drivers/node/current/aggregation.md, https://www.practical-mongodb-aggregations.com/guides/performance.html — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#core`
- [high] The `allowDiskUseByDefault` server parameter, introduced in MongoDB 6.0 and true by default, controls whether pipeline stages exceeding 100 MB of memory write to disk or raise an error. (verified as of 2026-10-15) Sources: https://www.mongodb.com/docs/manual/core/aggregation-pipeline-limits.md, https://www.mongodb.com/docs/manual/reference/command/aggregate.md, https://github.com/spring-projects/spring-data-mongodb/issues/4664 — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#core`
- [high] The `aggregate()` method accepts an `allowDiskUse` option to override the server default, allowing or prohibiting disk writes for stages exceeding the 100 MB memory limit. Sources: https://www.mongodb.com/docs/manual/reference/command/aggregate.md, https://www.mongodb.com/docs/drivers/node/current/aggregation.md, https://www.mongodb.com/docs/languages/python/pymongo-driver/current/aggregation.md, https://www.practical-mongodb-aggregations.com/guides/performance.html, https://studio3t.com/knowledge-base/articles/mongodb-aggregation-framework/ — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#core`
- [low] The per-operation memory limit is separate from the 100 MB per-stage limit and does not affect how stages spill to disk, while memory-intensive expressions not covered by the per-operation limit have a default 100 MB cap. Sources: https://www.mongodb.com/docs/manual/core/aggregation-pipeline-limits.md — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#core`
- [low] Atlas Free clusters impose specific limits including a maximum of 50 pipeline stages, a 32 MB in-memory sort limit, 0.5 GB storage, 100 operations per second, and no support for the `noTimeout` cursor option. Sources: https://www.mongodb.com/docs/atlas/reference/free-shared-limitations.md — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#antipatterns`
- [high] The error `QueryExceededMemoryLimitNoDiskUseAllowed` (code 292) occurs when a stage that can spill to disk exceeds the memory limit while `allowDiskUse` is `false`. Sources: https://www.mongodb.com/docs/manual/core/aggregation-pipeline-limits.md, https://blog.allegro.tech/2021/12/performance-evaluation-of-timeseries.html — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#troubleshooting`
- [low] Known issues include SERVER-74370 regarding the 100 MB limit for `$graphLookup`, SERVER-38632 where `allowDiskUse(true)` does not work as expected, and SERVER-102453 reverting SERVER-23980 in v8.1. (verified as of 2026-10-15) Sources: https://jira.mongodb.org/browse/SERVER-23980 — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#troubleshooting`
- Facts 26, 28, and 56 state that `$graphLookup` ignores `allowDiskUse` and has a strict 100 MB limit, while fact 30 states it automatically writes temporary files to disk if it consumes more than 100 MB. Sources: https://www.mongodb.com/docs/languages/python/pymongo-driver/current/aggregation.md, https://www.mongodb.com/docs/drivers/java/sync/current/aggregation.md, https://www.mongodb.com/docs/manual/reference/operator/aggregation/graphLookup.md, https://mongoosejs.com/docs/api/aggregate.html — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#disagreements`
- [low] Starting in MongoDB 9.0, a per-operation memory limit applies to the combined memory of all memory-tracked stages, defaulting to 1 GB or 20% of server process memory, whichever is greater. (verified as of 2026-10-15) Sources: https://www.mongodb.com/docs/manual/core/aggregation-pipeline-limits.md — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#core`
- [low] Atlas Free clusters limit data transfer to 10 GB in and 10 GB out per rolling seven-day period. Sources: https://www.mongodb.com/docs/atlas/reference/free-shared-limitations.md — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#antipatterns`
- [low] The error `ExceededMemoryLimit` (code 146) is raised for other operations that exceed the memory limit. Sources: https://www.mongodb.com/docs/manual/core/aggregation-pipeline-limits.md — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#troubleshooting`

## Facts and statements

- [high] Atlas Free clusters and Flex clusters do not support writing temporary files to disk, ignoring the `allowDiskUse` option and behaving as if it is set to `false`. Sources: https://www.mongodb.com/docs/manual/reference/command/aggregate.md, https://www.mongodb.com/docs/atlas/reference/free-shared-limitations.md, https://studio3t.com/knowledge-base/articles/mongodb-aggregation-framework/ — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#antipatterns`
- [medium] Profiler and diagnostic log messages can be used to monitor memory usage and errors in aggregation pipelines. Sources: https://www.mongodb.com/docs/manual/core/aggregation-pipeline-limits.md, https://www.mongodb.com/docs/manual/reference/command/aggregate.md — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#troubleshooting`
- [low] It is recommended not to set `AggregationOptions.allowDiskUse` by default to avoid unintended behavior. Sources: https://github.com/spring-projects/spring-data-mongodb/issues/4664 — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#patterns`
- [low] Atlas Free clusters have additional restrictions such as a maximum of 500 connections, 100 databases, 500 collections, 50 nested document levels, 95-byte namespace names, and no support for server-side JavaScript or private endpoints. Sources: https://www.mongodb.com/docs/atlas/reference/free-shared-limitations.md — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#antipatterns`
- [low] Atlas Free clusters do not support rolling index builds, automatic storage scaling, Performance Advisor, Real-Time Performance Panel, log downloads, or private endpoints, and they pause after 30 days of inactivity. Sources: https://www.mongodb.com/docs/atlas/reference/free-shared-limitations.md — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#antipatterns`
- [low] In Spring, the `allowDiskUse` option for aggregation pipelines defaults to `false` due to boolean typing, implicitly overriding the MongoDB server default behavior. Sources: https://github.com/spring-projects/spring-data-mongodb/issues/4664 — source: `~/.global-ai-hub/research/.pipeline/mongodb-2026-10-14/frb/memory-limits-and-allowdiskuse-7cf06d5afc/rabbithole-synthesis.md#antipatterns`

## Related concepts

- and — is a part of Memory Limits and allowDiskUse
- Memory — is a part of Memory Limits and allowDiskUse
- allowDiskUse — is a part of Memory Limits and allowDiskUse
- Limits — is a part of Memory Limits and allowDiskUse
