Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 8834C9F9398 for ; Fri, 7 Sep 2007 05:52:22 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 17101-07 for ; Fri, 7 Sep 2007 05:47:46 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from ptb-relay02.plus.net (ptb-relay02.plus.net [212.159.14.213]) by postgresql.org (Postfix) with ESMTP id CCA6F9F9705 for ; Fri, 7 Sep 2007 05:43:03 -0300 (ADT) Received: from [84.51.143.99] (helo=server3.office.archonet.com) by ptb-relay02.plus.net with esmtp (Exim) id 1ITZQa-0001Vt-PS; Fri, 07 Sep 2007 09:43:00 +0100 Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id BE133274057; Fri, 7 Sep 2007 09:42:59 +0100 (BST) Message-ID: <46E10F13.1060008@archonet.com> Date: Fri, 07 Sep 2007 09:42:59 +0100 From: Richard Huxton User-Agent: Thunderbird 2.0.0.6 (X11/20070728) MIME-Version: 1.0 To: Richard Yen CC: pgsql-performance@postgresql.org Subject: Re: postgres memory management issues? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/115 X-Sequence-Number: 26660 Richard Yen wrote: > Hi All, > > I've recently run into problems with my kernel complaining that I ran > out of memory, thus killing off postgres and bringing my app to a > grinding halt. > > I'm on a 32-bit architecture with 16GB of RAM, under Gentoo Linux. > Naturally, I have to set my shmmax to 2GB because the kernel can't > support more (well, I could set it to 3GB, but I use 2GB for safety). > > Shared_buffers is 200000 and max_connections is 600. OK, that's ~ 1.6GB shared-memory > Here is a snippet of my log output (I can give more if necessary): > Sep 5 18:38:57 tii-db2.oaktown.iparadigms.com Out of Memory: Kill > process 11696 (postgres) score 1181671 and children. OK, you've run out of memory at some point. > My understanding is that if any one postgres process's memory usage, > plus the shared memory, exceeds the kernel limit of 4GB, then the kernel > will kill the process off. Is this true? If so, would postgres have > some prevention mechanism that would keep a particular process from > getting too big? (Maybe I'm being too idealistic, or I just simply > don't understand how postgres works under the hood) You've got max_connections of 600 and you think individual backends are using more than 2.4GB RAM each? Long before that you'll run out of actual RAM+Swap. If you actually had 600 backends you'd be able to allocate ~24MB to each. You'd actually want much less, to allow for disk-cache in the OS. The important information missing is: 1. How much memory is in use, and by what (vmstat/top output) 2. What memory settings do you have in your postgresql.conf (work_mem, maintenance_work_mem) 3. What was happening at the time (how many connections etc) -- Richard Huxton Archonet Ltd