<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/understand-memory-management-in-amazon-rds-for-postgresql-to-avoid-out-of-memory-ll0sjlfsd" -->

---
title: Understand memory management in Amazon RDS for...
description: A deep technical walkthrough explains how PostgreSQL allocates shared and local memory on Amazon RDS for PostgreSQL and Aurora PostgreSQL, and how...
canonical: https://daily.dev/posts/understand-memory-management-in-amazon-rds-for-postgresql-to-avoid-out-of-memory-ll0sjlfsd
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Understand memory management in Amazon RDS for PostgreSQL to avoid out of memory | daily.dev
og:description: A deep technical walkthrough explains how PostgreSQL allocates shared and local memory on Amazon RDS for PostgreSQL and Aurora PostgreSQL, and how...
og:url: https://daily.dev/posts/understand-memory-management-in-amazon-rds-for-postgresql-to-avoid-out-of-memory-ll0sjlfsd
og:image: https://api.daily.dev/og/posts/Ll0SjLfSd.png
og:image:alt: Understand memory management in Amazon RDS for PostgreSQL to avoid out of memory
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Understand memory management in Amazon RDS for PostgreSQL to avoid out of memory

**[AWS Database Blog](https://daily.dev/sources/aws-database-blog)** · 23 min read · 0 upvotes · 0 comments

## Summary

A deep technical walkthrough explains how PostgreSQL allocates shared and local memory on Amazon RDS for PostgreSQL and Aurora PostgreSQL, and how misconfigured memory leads to disk spilling or OOM-triggered restarts. It covers shared_buffers defaults (25% RAM on RDS vs 75% on Aurora), work_mem and maintenance_work_mem behavior, parallel worker memory multiplication, and how to diagnose issues using CloudWatch metrics (FreeableMemory, SwapUsage), Database Insights, PostgreSQL logs, and Aurora-specific functions like aurora_stat_memctx_usage() and aurora_stat_plans(). It also demonstrates a reproduced OOM scenario and explains rds.enable_memory_management, an Aurora-only feature that cancels memory-hungry transactions before the OOM killer intervenes, with practical mitigation steps like session-level work_mem tuning and connection pooling.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://aws.amazon.com/blogs/database/understand-memory-management-in-amazon-rds-for-postgresql-to-avoid-out-of-memory>

## Questions this post answers

### Why does shared_buffers default to 75% of RAM on Aurora PostgreSQL but only 25% on RDS for PostgreSQL?

Aurora PostgreSQL sets shared_buffers to roughly 75% of instance RAM because its storage architecture has no local file system or OS page cache to reserve memory for, unlike RDS for PostgreSQL, which defaults to about 25% to leave room for per-backend allocations and the OS file system cache that backs its EBS-based storage.

_Teams sizing Aurora versus RDS instances can track configuration nuances like this on daily.dev._

### How can I prevent PostgreSQL from getting OOM killed on Aurora?

Aurora PostgreSQL includes rds.enable_memory_management, enabled by default, which monitors memory pressure and cancels the transaction requesting the allocation before the Linux OOM killer intervenes, keeping the database available rather than forcing a full restart. It works best when memory consumption rises gradually; instantaneous spikes across many concurrent sessions may still trigger OOM. RDS for PostgreSQL has no equivalent built-in mechanism.

_Engineers hardening PostgreSQL against OOM incidents can follow tuning guidance like this on daily.dev._

### How much work_mem does a query with parallel workers actually consume?

Each parallel worker gets its own full work_mem allocation per memory-consuming plan node, so with max_parallel_workers_per_gather set to 4, a single sort node can use up to 5x work_mem (one leader plus four workers). Hash joins and hash aggregates separately allocate up to work_mem times hash_mem_multiplier per node, so multiple nodes and workers multiply memory pressure quickly.

_Developers tuning parallel query memory budgets can reference calculations like this on daily.dev._

## Similar posts on daily.dev

- [Can your Postgres survive a bad query?](https://daily.dev/posts/can-your-postgres-survive-a-bad-query--sdf4kdxbn) · ClickHouse · 7 upvotes · 1 comments
- [Troubleshooting row lock contention in Amazon Aurora PostgreSQL: Part 1 – Understanding row lock contention in PostgreSQL](https://daily.dev/posts/troubleshooting-row-lock-contention-in-amazon-aurora-postgresql-part-1-understanding-row-lock-con-pjjvnrtvx) · AWS Database Blog · 0 upvotes · 0 comments
- [Don't give Postgres too much memory](https://daily.dev/posts/don-t-give-postgres-too-much-memory-xluq2yiti) · Lobsters · 1 upvotes · 0 comments
- [PostgreSQL 18 on Amazon Aurora and Amazon RDS: Performance enhancements](https://daily.dev/posts/postgresql-18-on-amazon-aurora-and-amazon-rds-performance-enhancements-lag8ehltp) · AWS Database Blog · 0 upvotes · 0 comments
- [Amazon RDS and Aurora expand R8gd and M8gd to additional Regions](https://daily.dev/posts/amazon-rds-and-aurora-expand-r8gd-and-m8gd-to-additional-regions-wgzz3wz0d) · AWS · 1 upvotes · 0 comments

---

Tags: [#aws](https://daily.dev/tags/aws), [#postgresql](https://daily.dev/tags/postgresql)

[View this post on daily.dev](https://daily.dev/posts/understand-memory-management-in-amazon-rds-for-postgresql-to-avoid-out-of-memory-ll0sjlfsd)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Understand memory management in Amazon RDS for PostgreSQL to avoid out of memory","url":"https://daily.dev/posts/understand-memory-management-in-amazon-rds-for-postgresql-to-avoid-out-of-memory-ll0sjlfsd","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/understand-memory-management-in-amazon-rds-for-postgresql-to-avoid-out-of-memory-ll0sjlfsd"},"datePublished":"2026-08-19T22:26:13.428Z","dateModified":"2026-09-13T21:10:22.722Z","description":"A deep technical walkthrough explains how PostgreSQL allocates shared and local memory on Amazon RDS for PostgreSQL and Aurora PostgreSQL, and how...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d2ba3d3eb185f218b58a54eec8d1d71e?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d2ba3d3eb185f218b58a54eec8d1d71e?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"AWS Database Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"AWS Database Blog","logo":"https://media.daily.dev/image/upload/s--En-avd2a--/f_auto,q_auto/v1780213446/logos/aws-database-blog?_a=BAMAMiWQ0","url":"https://daily.dev/sources/aws-database-blog"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/understand-memory-management-in-amazon-rds-for-postgresql-to-avoid-out-of-memory-ll0sjlfsd","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"aws,postgresql","timeRequired":"PT23M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"AWS Database Blog","item":"https://daily.dev/sources/aws-database-blog"},{"@type":"ListItem","position":3,"name":"Understand memory management in Amazon RDS for PostgreSQL to avoid out of memory"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/understand-memory-management-in-amazon-rds-for-postgresql-to-avoid-out-of-memory-ll0sjlfsd#faq","mainEntity":[{"@type":"Question","name":"Why does shared_buffers default to 75% of RAM on Aurora PostgreSQL but only 25% on RDS for PostgreSQL?","acceptedAnswer":{"@type":"Answer","text":"Aurora PostgreSQL sets shared_buffers to roughly 75% of instance RAM because its storage architecture has no local file system or OS page cache to reserve memory for, unlike RDS for PostgreSQL, which defaults to about 25% to leave room for per-backend allocations and the OS file system cache that backs its EBS-based storage. Teams sizing Aurora versus RDS instances can track configuration nuances like this on daily.dev."}},{"@type":"Question","name":"How can I prevent PostgreSQL from getting OOM killed on Aurora?","acceptedAnswer":{"@type":"Answer","text":"Aurora PostgreSQL includes rds.enable_memory_management, enabled by default, which monitors memory pressure and cancels the transaction requesting the allocation before the Linux OOM killer intervenes, keeping the database available rather than forcing a full restart. It works best when memory consumption rises gradually; instantaneous spikes across many concurrent sessions may still trigger OOM. RDS for PostgreSQL has no equivalent built-in mechanism. Engineers hardening PostgreSQL against OOM incidents can follow tuning guidance like this on daily.dev."}},{"@type":"Question","name":"How much work_mem does a query with parallel workers actually consume?","acceptedAnswer":{"@type":"Answer","text":"Each parallel worker gets its own full work_mem allocation per memory-consuming plan node, so with max_parallel_workers_per_gather set to 4, a single sort node can use up to 5x work_mem (one leader plus four workers). Hash joins and hash aggregates separately allocate up to work_mem times hash_mem_multiplier per node, so multiple nodes and workers multiply memory pressure quickly. Developers tuning parallel query memory budgets can reference calculations like this on daily.dev."}}]}
```

