I'm running Postgresql on a Ubuntu server and need to be able to monitor its memory usage. Currently I have scripts running in a one-minute cron job that monitor/log various statistics and need to also monitor/log the current memory usage of Postgresql. I've searched around and haven't been able to find much, other than the fact that Postgresql makes good use of shared memory so the values given by a program such as 'top' aren't accurate.

How can I monitor what the total memory usage of Postgresql is at any given time? This data will later be used to create graphs for analysis.

2 Answers 2


Memory usage in linux in general and for Postgres in particular is a pretty complex subject, a good starting point is Bruce Momjians blog covering the subject and the usage of smem. It is well worth following the links in Chris Seibenmanns blog on the subject.

  • Thanks for the links, but it appears that smem won't work either as the kernel version is too old. Good articles though.
    – Rauffle
    Commented Feb 8, 2012 at 22:29

You can use pmap command to get the used memory of a process:

# pmap -p PID
  • Unfortunately pmap isn't very useful in this case as Postgresql uses a lot of shared memory. At times the total memory reported by tools like pmap for Postgresql is greater than the total usable memory on the system because of this.
    – Rauffle
    Commented Feb 8, 2012 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.