Why does PostgreSQL use so much memory?

Despite appearances, this is absolutely normal, and there’s actually nowhere near as much memory being used as tools like?top?or the Windows process monitor say PostgreSQL is using.

Tools like?top?and the Windows process monitor may show many?postgres?instances (see above), each of which appears to use a huge amount of memory. Often, when added up, the amount the postgres instances use is many times the amount of memory actually installed in the computer!

This is a consequence of how these tools report memory use. They generally don’t understand shared memory very well, and show it as if it was memory used individually and exclusively by each postgres instance. PostgreSQL uses a big chunk of shared memory to communicate between its backends and cache data. Because these tools count that shared memory block once per?postgres?instance instead of counting it once for?all?postgres?instances, they massively over-estimate how much memory PostgreSQL is using.