Glossary — in plain language

Memory context (MemoryContext)

Also called: MemoryContext, allocation arena, mcxt

In plain English

A memory context is a named arena that owns a group of allocations. PostgreSQL allocates from the current context with palloc and, instead of freeing objects one by one, resets or deletes the whole context — reclaiming every allocation inside it at once. Contexts form a tree rooted at TopMemoryContext; deleting a parent frees all its children.

Why it matters

This is how PostgreSQL avoids leaks despite rarely calling free: when a query or a single tuple’s processing ends, its context is wiped wholesale. It also makes memory diagnosable — each context is named, so you can see exactly which arena is consuming RAM.

Was this helpful?

← Browse the full glossary