pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedA question about memory usage
5+ messages / 4 participants
[nested] [flat]
* A question about memory usage
@ 2007-06-12 16:55 Arnau Rebassa i Villalonga <arnau.rebassa@androme.es>
0 siblings, 1 reply; 5+ messages in thread
From: Arnau Rebassa i Villalonga @ 2007-06-12 16:55 UTC (permalink / raw)
To: pgsql-admin
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. To check this I have executed the
free command and I get the following results:
total used free shared buffers cached
Mem: 4153180 3988536 164644 0 161400 3117900
-/+ buffers/cache: 709236 3443944
Swap: 6215672 64 6215608
So my question is, what I'm doing wrong? because the swap it's almost
empty
Thank you very much
--
Arnau
^ permalink raw reply [nested|flat] 5+ messages in thread
* A question about memory usage
@ 2007-06-12 17:00 Arnau Rebassa i Villalonga <arnau.rebassa@androme.es>
0 siblings, 0 replies; 5+ messages in thread
From: Arnau Rebassa i Villalonga @ 2007-06-12 17:00 UTC (permalink / raw)
To: pgsql-admin
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. To check this I have executed the
free command and I get the following results:
total used free shared buffers cached
Mem: 4153180 3988536 164644 0 161400 3117900
-/+ buffers/cache: 709236 3443944
Swap: 6215672 64 6215608
So my question is, what I'm doing wrong? because the swap it's almost
empty
Thank you very much
--
Arnau
^ permalink raw reply [nested|flat] 5+ messages in thread
* A question about memory usage
@ 2007-06-12 17:26 Arnau <arnaulist@andromeiberica.com>
0 siblings, 1 reply; 5+ messages in thread
From: Arnau @ 2007-06-12 17:26 UTC (permalink / raw)
To: pgsql-admin
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. To check this I have executed the
free command and I get the following results:
total used free shared buffers cached
Mem: 4153180 3988536 164644 0 161400 3117900
-/+ buffers/cache: 709236 3443944
Swap: 6215672 64 6215608
So my question is, what I'm doing wrong? because the swap it's almost
empty
Thank you very much
--
Arnau
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: A question about memory usage
@ 2007-06-12 17:46 Adam Tauno Williams <adamtaunowilliams@gmail.com>
parent: Arnau <arnaulist@andromeiberica.com>
0 siblings, 0 replies; 5+ messages in thread
From: Adam Tauno Williams @ 2007-06-12 17:46 UTC (permalink / raw)
To: pgsql-admin
> 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. To check this I have executed the
> free command and I get the following results:
> total used free shared buffers cached
> Mem: 4153180 3988536 164644 0 161400 3117900
> -/+ buffers/cache: 709236 3443944
> Swap: 6215672 64 6215608
> So my question is, what I'm doing wrong? because the swap it's almost
> empty
You are misunderstanding what these numbers mean on a UNIX system.
For starters -
http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html
And if you are not swapping, and your OS's cache is that huge, why
bother?
Use "ipcs" to display the allocation of shared memory.
--
Adam Tauno Williams, Network & Systems Administrator
Consultant - http://www.whitemiceconsulting.com
Developer - http://www.opengroupware.org
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: A question about memory usage
@ 2007-06-13 14:08 Tom Lane <tgl@sss.pgh.pa.us>
parent: Arnau Rebassa i Villalonga <arnau.rebassa@androme.es>
0 siblings, 0 replies; 5+ messages in thread
From: Tom Lane @ 2007-06-13 14:08 UTC (permalink / raw)
To: arnaulist@andromeiberica.com; +Cc: pgsql-admin
Arnau Rebassa i Villalonga <arnau.rebassa@androme.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
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2007-06-13 14:08 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-06-12 16:55 A question about memory usage Arnau Rebassa i Villalonga <arnau.rebassa@androme.es>
2007-06-13 14:08 ` Tom Lane <tgl@sss.pgh.pa.us>
2007-06-12 17:00 A question about memory usage Arnau Rebassa i Villalonga <arnau.rebassa@androme.es>
2007-06-12 17:26 A question about memory usage Arnau <arnaulist@andromeiberica.com>
2007-06-12 17:46 ` Adam Tauno Williams <adamtaunowilliams@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox