Re: A question about memory usage

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: arnaulist(at)andromeiberica(dot)com
Cc: "pgsql-admin(at)postgresql(dot)org >> \"pgsql-admin(at)postgresql(dot)org\"" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: A question about memory usage
Date: 2007-06-13 14:08:29
Message-ID: 9524.1181743709@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Arnau Rebassa i Villalonga <arnau(dot)rebassa(at)androme(dot)es> writes:
> I have a server with 4GB of RAM and I wanted to know how much memory
> is being used by a PostgreSQL. To do so I have executed the following:

> ps -A -o rss,vsz,command|grep postgres | awk '{rss += $1; vsz += $2 }
> END { print "Real: ",rss/1024"MB Virtual: ",vsz/1024"MB" }'

Depending on the details of your ps command, this is likely counting
Postgres' shared memory area over again for each backend. It's
definitely counting the executable-program image over again for each
backend, even though on any modern system those pages will be shared.
So it's no surprise that you get a number a lot larger than the actual
RAM footprint.

I don't know of any good portable way to get the number you want :-(.
If your ps can distinguish shared and unshared pages, adding up all the
unshared pages and counting one instance of the shared pages will be
reasonably close.

regards, tom lane

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Leif B. Kristensen 2007-06-13 14:42:58 Re: psql : Error: Cannot stat /pgdata/8.2/main
Previous Message Tom Lane 2007-06-13 13:45:52 Re: [GENERAL] psql : Error: Cannot stat /pgdata/8.2/main