[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: A question about memory usage



Andrew Sackville-West wrote:
On Tue, Jun 12, 2007 at 11:32:00AM -0400, Scott Gifford wrote:
Arnau <arnaulist@andromeiberica.com> writes:

Hi all,

   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" }'

And the result is:
   Real:  157.59MB Virtual:  6359.04MB

So I understand that amount of virtual memory must be swapped to disk
as it's bigger that my physical memory.
Hi Arnau,

Your calculation is incorrect.  Many of the PostgreSQL processes are
sharing the same memory, so while each may be using, for example,
500MB of memory, probably 450MB may be the same in each process.
Memory is shared between parent processes and children and when items
are mapped into memory with mmap, including the executable and shared
libraries.

Figuring out exactly how much memory a set of processes are using is a
difficult problem.  Looking in /proc/$pid/maps is a good place to
start.


probably the easiest thing is to use free in two states: with the
process running and without.
if all other factors are the same, then the difference would be the
amount of memory used by the process in question.

or is there something wrong with that?

I'm afraid that's not possible :) In fact what I really want to do is monitor how much memory PostgreSQL is using.

--
Arnau



Reply to: