Glossary — in plain language

palloc / pfree

Also called: palloc, pfree, MemoryContextAlloc

In plain English

palloc(size) is PostgreSQL’s internal allocator call. Unlike malloc, it takes no context argument — it allocates from the global CurrentMemoryContext, so where the memory lands depends on the context in effect. pfree releases one chunk, but it is rarely used: the normal pattern is to let the context be reset or deleted later.

Why it matters

Because palloc follows CurrentMemoryContext, the same call can put memory in a short-lived per-tuple arena or a long-lived cache depending on the surrounding MemoryContextSwitchTo. Allocating in the wrong context is the canonical PostgreSQL memory leak.

Was this helpful?

← Browse the full glossary