pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mike Rylander <mrylander@gmail.com>
Cc: pgsql general <pgsql-general@postgresql.org>
Subject: Re: Memory Leakage Problem
Date: Wed, 07 Dec 2005 23:38:53 -0500
Message-ID: <6353.1134016733@sss.pgh.pa.us> (raw)
In-Reply-To: <b918cf3d0512071946m3cbfc630y679e0350a7f6b864@mail.gmail.com>
References: <c10e7feb0512060122u33a9c8eakb178525f3834b00@mail.gmail.com>
	<1133891282.11803.7.camel@state.g2switchworks.com>
	<c10e7feb0512061816o21305ac7n576694f2624dc6ed@mail.gmail.com>
	<1133991204.11803.43.camel@state.g2switchworks.com>
	<c10e7feb0512071825h30c93c00kdf5ea2a11e613f0b@mail.gmail.com>
	<b918cf3d0512071946m3cbfc630y679e0350a7f6b864@mail.gmail.com>

Mike Rylander <mrylander@gmail.com> writes:
> To cut to the chase, here are
> some numbers for everyone to digest:
>            total gnu ps resident size
> # ps ax -o rss|perl -e '$x += $_ for (<>);print "$x\n";'
> 5810492
>            total gnu ps virual size
> # ps ax -o vsz|perl -e '$x += $_ for (<>);print "$x\n";'
> 10585400
>            total gnu ps "if all pages were dirtied and swapped" size
> # ps ax -o size|perl -e '$x += $_ for (<>);print "$x\n";'
> 1970952

I wouldn't put any faith in those numbers at all, because you'll be
counting the PG shared memory multiple times.

On the Linux versions I've used lately, ps and top report a process'
memory size as including all its private memory, plus all the pages
of shared memory that it has touched since it started.  So if you run
say a seqscan over a large table in a freshly-started backend, the
reported memory usage will ramp up from a couple meg to the size of
your shared_buffer arena plus a couple meg --- but in reality the
space used by the process is staying constant at a couple meg.

Now, multiply that effect by N backends doing this at once, and you'll
have a very skewed view of what's happening in your system.

I'd trust the totals reported by free and dstat a lot more than summing
per-process numbers from ps or top.

> Now, I'm not blaming Pg for the apparent discrepancy in calculated vs.
> reported-by-free memory usage, but I only noticed this after upgrading
> to 8.1.

I don't know of any reason to think that 8.1 would act differently from
older PG versions in this respect.

			regards, tom lane



view thread (22+ messages)  latest in thread

Message-ID: <6353.1134016733@sss.pgh.pa.us>
Permalink:  ../6353.1134016733@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/6353.1134016733@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mrylander@gmail.com, pgsql-general@postgresql.org
  Subject: Re: Memory Leakage Problem
  In-Reply-To: <6353.1134016733@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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