On Fri, 14 Aug 2009, Scott Carey wrote:
> The memory used by postgres for shared memory is the largest of all SHR
> columns for postgres columns. Or, about 7.9GB. So, postgres is using
> about 7.9GB for shared memory, and very little for anything else.
It's a good idea to check this result against the actual shared memory
block allocated. If the server has been up long enough to go through all
of shared_buffers once, the results should be close. You can look at the
block under Linux using "ipcs -m"; the one you want should look something
like this:
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x0052e2c1 21757972 gsmith 600 548610048 10
That represents a bit over 512MB worth of allocated memory for the server.
Alternately, you can use "pmap -d" on a PostgreSQL process to find the
block, something like this works:
$ pmap -d 13961 | egrep "^Address|shmid"
Address Kbytes Mode Offset Device Mapping
96c41000 535752 rw-s- 0000000000000000 000:00009 [ shmid=0x14c0014 ]
I have given up on presuming the summary values top shows are good for
anything on Linux. I look at /proc/meminfo to see how much RAM is free,
and to figure out what's going on with the server processes I use:
ps -e -o pid,rss,vsz,size,cmd | grep postgres
And compute my own totals (one of these days I'm going to script that
process). Useful reading on this topic:
http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html
http://mail.nl.linux.org/linux-mm/2003-03/msg00077.html
http://forums.gentoo.org/viewtopic.php?t=175419
Most confusion about what's going on here can be resolved by spending some
quality time with pmap.
--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD