Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id E5712650E99 for ; Tue, 24 Jun 2008 12:48:18 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 25589-03 for ; Tue, 24 Jun 2008 12:48:14 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id E6FD5650E23 for ; Tue, 24 Jun 2008 12:48:13 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m5OFmBgQ018399; Tue, 24 Jun 2008 11:48:11 -0400 (EDT) To: Guillaume Lelarge cc: Marc Cousin , pgsql-admin@postgresql.org Subject: Re: plpgsql function seems to be leaking memory In-reply-to: <486114BF.7040901@lelarge.info> References: <200806241056.29589.mcousin@sigma.fr> <16759.1214319370@sss.pgh.pa.us> <486114BF.7040901@lelarge.info> Comments: In-reply-to Guillaume Lelarge message dated "Tue, 24 Jun 2008 17:37:35 +0200" Date: Tue, 24 Jun 2008 11:48:11 -0400 Message-ID: <18398.1214322491@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200806/208 X-Sequence-Number: 29546 Guillaume Lelarge writes: > Tom Lane a écrit : >> What do you have shared_buffers set to? I think you might be getting >> fooled by top's treatment of shared memory (ie, it starts to count >> shared pages after the process touches them for the first time). > That's what I thought at first when I saw Marc's email. I tried his > example many times, with different values for shared_buffers. RSS column > climbs until it reaches more or less the shared_buffers configuration. > But, if I launch another psql, this process will have a much lower value > on the RSS column. Shouldn't it get the RSS at the same value, even when > the process starts ? No, that's exactly the point. Linux top includes in a process's reported size its actual private space, plus however many pages of shared memory that process has physically accessed so far. So any PG backend that's doing a material amount of table access is going to show an RSS that starts low and creeps up to roughly the size of your shared memory block, quite independently of what its actual private space usage is. It's just a matter of how many buffers it has had occasion to use. This is all pretty OS-dependent. Some systems don't count shared memory at all (HPUX seems not to), and some other ones report a separate total for shared memory so that you can mentally subtract it. regards, tom lane