Memory Limits and allowDiskUse
Parent: MongoDB Aggregation Pipeline · Published reference · snapshot 2026-10-15 · viability 3.05 / 5 (skip)
Also known as: Per-operation memory limit in 9.0
↓ Facts as markdownall context files
Depth-first rabbithole dossier for Memory Limits and allowDiskUse; source-anchored research pack.
These notes link each claim to its source. Some citations identify archived research reports that are no longer hosted on this site. A published reference means the content is available; it does not certify independent review or accuracy.Read the editorial policy and follow the sources before relying on a claim.
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]
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]
- [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]
- [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]
- [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]
- [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]
- [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]
- [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]
- [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]
- 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]
- [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]
- [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]
- [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]
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]
- [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]
- [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]
- [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]
- [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]
- [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]
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
Children
- No children recorded.