Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

migrated from Feb 8 '12 at 19:06

This question came from our site for professional and enthusiast programmers.

up vote 7 down vote accepted

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.

share|improve this answer
Thanks for the links, but it appears that smem won't work either as the kernel version is too old. Good articles though. – Rauffle Feb 8 '12 at 22:29

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

# pmap -p PID
share|improve this answer
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 Feb 8 '12 at 20:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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