Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ifksB-0000Fu-TE for pgsql-bugs@arkaria.postgresql.org; Fri, 13 Dec 2019 13:20:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ifksA-0007Aj-L1 for pgsql-bugs@arkaria.postgresql.org; Fri, 13 Dec 2019 13:20:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ifksA-0007Ac-8V for pgsql-bugs@lists.postgresql.org; Fri, 13 Dec 2019 13:20:46 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ifks6-0001cI-Qm for pgsql-bugs@lists.postgresql.org; Fri, 13 Dec 2019 13:20:45 +0000 Received: by mail-wr1-x42c.google.com with SMTP id t2so6655026wrr.1 for ; Fri, 13 Dec 2019 05:20:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8firR1iiqF3/V4yINDzdT8olsJ7BIR5nurFaITzp0gY=; b=GAcGSsy/S+vrpnIYi8PDxqrcLksNQ+IPFF8/jv3QuyBAZljCx3tLB/A1jXxEgjm4/6 zxvpQfWJpvOe/vio6KwdykqemPpB0TvKoo+7Xd3GiRiLraO/fnFtf3rwzA5gizAPVso/ mOmJz5Dhvq13/4F0ciI7syFEGwf6gjRGEKA36dk46sysf1slzclC4Nt2632lS2Q9xwfA RXHQM934mRQFDBJ7AHDC8RqYJRnLJIIoFwDwkErba2zvq+Cpi4sSukmsWjsG3SY/p3aT 93uTHUFw+tAr4lZvuVxJcIBgdALiqAzHTwU0/C99siSJObrc1sLiGImZXvfsfs7wTE/i OkUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8firR1iiqF3/V4yINDzdT8olsJ7BIR5nurFaITzp0gY=; b=DaVD3Ah6Pz4mC4vA+VU3DR83soIQz+lXF7GKtW3yUCkLecFW4bb9PNKcshPsRRg5CO SWRv6uIXdE9GwxDzkh31hLk8ydOu6uTt5mb0qxx75/u2MVtzfg663kFHYHNUaRc+sPX8 PdLQAnLIxNeD/wXZj+jvAg3xzAY1a0n91dsR+ewjYKjOEP1+2odSjufHTmUL3KLpMDFm h5KHXqL9c+HewIdWQLYtxaXzLBo2FBUF4cs4DjE44cu7sIQGqDu2L3qcLCPU0a7Ta/F/ NabViAroHi/Zk+VnRiSNwEYiLQbJJiN/jFbUnrGR8Wcpl0p6iG6Z4r+3BDXZ79425tN3 um4A== X-Gm-Message-State: APjAAAV3Y65EF9+iigm6qC64GDgDGJF/6xD6kdnfi/2GwvVAGZ9DuL1c PAxMXreNFir6ZR929BPBAOgyd6Agi6E= X-Google-Smtp-Source: APXvYqyKeI0RwQyhTYeKEqTvrpi1ezJvZSDlN290lJsz9M2OO0+WXAAxu561zmF/K4MNmqejNHEd/w== X-Received: by 2002:adf:dd51:: with SMTP id u17mr12350131wrm.290.1576243241741; Fri, 13 Dec 2019 05:20:41 -0800 (PST) Received: from localhost (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id e6sm9965695wru.44.2019.12.13.05.20.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2019 05:20:39 -0800 (PST) Date: Fri, 13 Dec 2019 14:20:36 +0100 From: Tomas Vondra To: Roman Cervenak Cc: Tom Lane , pgsql-bugs@lists.postgresql.org Subject: Re: Memory leak (possibly connected to postgis) leading to server crash Message-ID: <20191213132036.3m27dlquaxoorkja@development> References: <20191206110154.v7yshqsn32zyxx4q@development> <20191206124119.qe2xaffcbkcbmve3@development> <18069.1576082949@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Dec 13, 2019 at 11:51:55AM +0100, Roman Cervenak wrote: >With "postgresql-12-dbgsym" installed, >call MemoryContextStats(TopMemoryContext) succeeded on postgres backend >process with high memory consumption. >I cut it from server logs, see attached file (I have redacted queries and >table structures, I left SELECT parts where is visible that geometric >operations are involved). > The way I read the context stats, the memory leak has to be somewhere in a library calling malloc directly, or something like that. Because per the log, the PostgreSQL memory contexts are a whopping 5MB in total: Grand total: 5683464 bytes in 1082 blocks; 2027536 free (362 chunks); 3655928 So this is likely a memory leak either somewhere in PostGIS (I see ~200 malloc calls in the current source code) or maybe in one of the libraries it's using. I think at this point we need to get more information about the queries and data, or even better a reproducer. Or try running the queries under valgrind, which does have a memory leak detector. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services