# maximum\_memory

> **📝 Note**: This page applies only to versions before 8.1. For 8.1 and later versions refer to [Disk Spilling](https://docs.singlestore.com/db/v9.1/user-and-cluster-administration/maintain-your-cluster/managing-memory/disk-spilling.md)

SingleStore will not allocate more than `maximum_memory` megabytes of memory. If a `SELECT` query’s memory allocations put the memory usage by SingleStore over `maximum_memory`, query execution stops and an error message is generated.

By default, `maximum_memory` is set to 90% of the physical memory on the host, or physical memory minus 10GB, whichever value is greater.

As Kubernetes does not support swap, `maximum_memory` for the Operator is set to 90% of physical memory, or physical memory minus 10 GB, whichever is larger

Query compilations whose allocations exceed this limit will also terminate the server. See [Code Generation](https://docs.singlestore.com/db/v9.1/query-data/advanced-query-topics/code-generation.md) for more information on query compilations.

SingleStore supports disk spilling. Instead of query failure, disk spilling allows query execution to continue by moving certain query operators onto disk and out of memory.&#x20;

When a node's memory load is above 75% and in-memory data structures (for the current thread) are at least 100MB, the intermediate result of the operation spills to disk in the data/spill directory. The node memory load ratio and threshold are configurable variables: `spilling_node_memory_threshold_ratio` and `spilling_query_operator_memory_threshold`, respectively. Disk spilling will usually reduce memory usage (can spill at most 64x physical memory), but may result in longer execution time. SingleStore recommends using an SSD (A solid-state drive is a storage device. It is a non-volatile medium that stores persistent data on solid-state flash memory.) for the spilling directory since it can result in up to a tenfold increase in performance.

Currently, the following query operator(s) can be spilt onto disk:

* `GROUP BY`
* `SORT` or `ORDER BY`
* [Window Functions](https://docs.singlestore.com/db/v9.1/developer-resources/functional-extensions/working-with-window-functions.md)
* [Hash Joins](https://docs.singlestore.com/db/v9.1/query-data/query-plan-operations/#UUID-6b414630-f464-acdf-8041-07c206499184.md)

> **📝 Note**: Disk spilling must be enabled by setting the engine variable, `enable_spilling` to `ON`. Starting with version 7.8, ON is the default value for `enable_spilling`. See the [Sync Variables Lists](https://docs.singlestore.com/db/v9.1/reference/configuration-reference/engine-variables/list-of-engine-variables/#sync-variables-lists.md) page for more information.

***

Modified at: October 24, 2024

Source: [/db/v9.1/user-and-cluster-administration/maintain-your-cluster/managing-memory/maximum-memory/](https://docs.singlestore.com/db/v9.1/user-and-cluster-administration/maintain-your-cluster/managing-memory/maximum-memory/)

(An index of the documentation is available at /llms.txt)
