Improved memory management in Aurora PostgreSQL - Amazon Aurora

Improved memory management in Aurora PostgreSQL

Customer workloads exhausting the free memory available in the DB instance leads to database restart by the operating system causing database unavailability. Aurora PostgreSQL has introduced improved memory management capabilities that proactively prevents stability issues and database restarts caused by insufficient free memory. This improvement is available by default in the following versions:

  • 15.3 and higher 15 versions

  • 14.8 and higher 14 versions

  • 13.11 and higher 13 versions

  • 12.15 and higher 12 versions

  • 11.20 and higher 11 versions

To improve the memory management, it does the following:

  • Cancelling database transactions that request more memory when the system is approaching critical memory pressure.

  • The system is said to be under critical memory pressure, when it exhausts all the physical memory and is about to exhaust the swap. In these circumstances, any transaction that requests memory will be cancelled in an effort to immediately reduce memory pressure in the DB instance.

  • Essential PostgreSQL launchers and background workers such as autovacuum workers are always protected.

Configuring memory management parameters

To turn on memory management

This feature is turned on by default. An error message is displayed when a transaction is cancelled due to insufficient memory as shown in the following example:

ERROR: out of memory Detail: Failed on request of size 16777216.
To turn off memory management

To turn off this feature, connect to the Aurora PostgreSQL DB cluster with psql and use the SET statement for the parameter values as mentioned below.

For Aurora PostgreSQL versions 11.21, 12.16, 13.12, 14.9, 15.4, and older versions:

postgres=>SET rds.memory_allocation_guard = true;

The default value of rds.memory_allocation_guard parameter is set to false in the Parameter group.

For Aurora PostgreSQL 12.17, 13.13, 14.10, 15.5, and higher versions:

postgres=>rds.enable_memory_management = false;

The default value of rds.enable_memory_management parameter is set to true in the Parameter group.

Setting the values of these parameters in the DB cluster parameter group prevents the queries from being canceled. For more information about DB cluster parameter group, see Working with parameter groups.

The value of these dynamic parameters can also be set at a session level to include or exclude a session in improved memory management.


We don't recommend turning off this feature as it might lead to out-of-memory error that can cause workload induced database restart due to the memory exhaustion in the system.