On 14 November 2012 06:47, Craig Ringer <craig@2ndquadrant.com> wrote:
> Yes, it's absurd that it's so hard to work out how much memory Pg uses. It'd
> be nice if Pg provided better tools for this by allowing the postmaster to
> interrogate backends' memory contexts, though that'd only report how much
> memory Pg thought it was using, not how much memory it was actually using
> from the OS. Really, OS-specific tools are required, and nobody's written
> them - at least, I'm not aware of any that've been published.
I wrote a GDB Python script that interrogates a running backend about
memory context information, walking a tree of contexts, which is based
almost entirely on standard infrastructure used by
MemoryContextStats(). It's quite possible. You're quite right to say
that OS-specific tools would probably do a more satisfactory job,
though, particularly if you're not interested in *what* Postgres is
doing with memory, but need to summarise it usefully.
--
Peter Geoghegan http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services