Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 1FFAFFC9802 for ; Thu, 26 Jul 2012 23:31:48 -0300 (ADT) Received: from mail-gh0-f174.google.com ([209.85.160.174]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SuaLB-0006f8-O1 for pgsql-bugs@postgresql.org; Fri, 27 Jul 2012 02:31:47 +0000 Received: by ghrr11 with SMTP id r11so2728042ghr.19 for ; Thu, 26 Jul 2012 19:31:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=GRR7cREO4G/JiVyj2qLCoom3DLW9R+wrf9Ds9nJYLWY=; b=By+yV9TrOkHOOtr2nI+p77RtD2XYLeTuBIvhQGkwDvTwp/UAMrswve4e/JBIMPBL98 lx1gWOdf0F/i2kVRFvahOz/oDBa7h93AM5Js4px09/K7lXXq81zVHJ/lxWLXpFLHUy8r OwgYbtZOU8HHegodJf8GKwltXHX9LKs64qGTvsIcvxLocuYCZtKufWhhBHhuC8fguaB2 9RmE6KSsyA9T47IV3VtRGcA5hjSVzizBCWHSNssV907LhMaQ0yqVdMn5gLXC2SICbcvt wcLLtNiQuEO3Sfmv95yemGneLLyPegMC+Ad1AmQW2S8BKNo7kuCQEfz7oefOl17c3aZN xJiw== Received: by 10.50.183.200 with SMTP id eo8mr3352005igc.63.1343356291058; Thu, 26 Jul 2012 19:31:31 -0700 (PDT) Received: from ayaki.localdomain (124-169-186-146.dyn.iinet.net.au. [124.169.186.146]) by mx.google.com with ESMTPS id rd8sm1784049igb.3.2012.07.26.19.31.28 (version=SSLv3 cipher=OTHER); Thu, 26 Jul 2012 19:31:30 -0700 (PDT) Message-ID: <5011FD7E.305@ringerc.id.au> Date: Fri, 27 Jul 2012 10:31:26 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: luben karavelov CC: pgsql-bugs@postgresql.org Subject: Re: BUG #6763: Severe memory leak with arrays and hstore References: <5010FD0F.4020400@ringerc.id.au> <10398EEF-03DE-405E-B276-06F73ABF9E3A@mail.bg> In-Reply-To: <10398EEF-03DE-405E-B276-06F73ABF9E3A@mail.bg> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQnf9XC0HLVTjc0sbw/67smHtCo9TvU8I5kshb9ItQCyC0FSntndTDOM5s1H38a9iV97Vl0g X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/213 X-Sequence-Number: 33689 On 07/26/2012 09:55 PM, luben karavelov wrote: > Ok, I will do the procedure again with taking notes on each step. Thankyou for taking the time to do this in detail. > First, here are the results of the queries you asked: > count | to_char > ---------+----------- > 1257262 | 2.26 > pg_size_pretty > ---------------- > 264 MB OK, none of that looks obviously insanely huge to me. That's a lot of hstores, but with your query I wouldn't expect them to all sit around in memory, and nothing individually is particularly huge. > Also there are max of 34 rows per user_id in old_prefs Thanks, I forgot to ask that. Again, nothing particularly big. > USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND > postgres 19121 0.0 0.0 2266944 3448 ? Ss 15:23 0:00 postgres: pg pg 10.0.2.71(51734) idle > postgres 19121 0.8 7.1 3081772 582712 ? Ss 15:23 0:02 postgres: pg pg 10.0.2.71(51734) idle > postgres 19121 1.1 8.5 3176164 697444 ? Ss 15:23 0:05 postgres: pg pg 10.0.2.71(51734) idle > postgres 19121 0.7 9.6 3210224 791404 ? Ss 15:23 0:08 postgres: pg pg 10.0.2.71(51734) idle > postgres 19121 0.9 10.8 3277412 889860 ? Ss 15:23 0:11 postgres: pg pg 10.0.2.71(51734) idle > postgres 19121 0.9 11.5 3277412 945560 ? Ss 15:23 0:15 postgres: pg pg 10.0.2.71(51734) idle > postgres 19121 1.2 16.2 3736968 1331796 ? Ss 15:23 0:20 postgres: pg pg 10.0.2.71(51734) idle > 1. Backend does not free allocated memory between transactions. > 2. Rolled back transactions also leak memory. > 3. Leaked memory is not linear to work done - 2 transactions with 200k keys will leak less than 1 transaction with 400k keys Ouch. Sure looks like a leak to me, yeah. Thankyou for taking the time to do this. It's common to see "leaks" reported here that are really just queries that require lots of memory, so the first response tends to be somewhat cautious. This doesn't look like one of those reports. I don't know if I can be much use with the actual tracking down of the leak, but there certainly appears to be one, and you've provided a pretty clear illustration of it. -- Craig Ringer