GridGain Developers Hub

Memory Quotas Configuration

Memory quotas can be used to prevent GridGain nodes from running out of memory when executing SQL queries that return large result sets. A query loads objects from caches into memory. If there are too many objects, the objects are too large, or multiple large queries are executed on the node at the same time, the JVM can run out of memory. When memory quotas are configured, the SQL engine imposes a limit on the heap memory available to queries.

Quotas are configured for each node individually. You can have different limits on different nodes, depending on the amount of RAM available to the nodes. Additionally, you can set a cluster-wide limit to how much of the memory quota can be used up by a single SQL query.

Memory quota size can be configured in:

  • Kilobytes - append 'K' or 'k', for example: 10k, 400K;

  • Megabytes - append 'M' or 'm', for example: 60m, 420M;

  • Gigabytes - append 'G' or 'g', for example: 7g, 2G;

  • Percent of heap - append the '%' sign, for example: 45%, 80%.

Node-Wide Memory Quota

By default, a quota for SQL queries is set to 60% of the heap memory available to the node. You can change this limit by setting the sql.nodeMemoryQuota node configuration property. To disable the memory quota, set it to 0. You can use the CLI tool to set it:

node config update --node-url http://localhost:10300 {sql.nodeMemoryQuota:"1000M"}

If the node memory quota is exceeded, the query is interrupted and the SQL query ran out of memory: Node quota was exceeded error is returned.

Query-Wide Memory Quota

By default, each individual query can use the entire memory quota. This may be undesirable in environments that run multiple large queries in parallel. You can use the sql.statementMemoryQuota cluster configuration property to limit the amount of memory that can be allocated to a single query.

cluster config update --cluster-endpoint-url http://localhost:10300 {sql.statementMemoryQuota:"10M"}

If the statement memory quota is exceeded, the query is interrupted and the SQL query ran out of memory: Statement quota was exceeded error is returned.