Re: Memory leak (possibly connected to postgis) leading to servercrash - Mailing list pgsql-bugs

From Tomas Vondra
Subject Re: Memory leak (possibly connected to postgis) leading to servercrash
Date
Msg-id 20191213132036.3m27dlquaxoorkja@development
Whole thread Raw
In response to Re: Memory leak (possibly connected to postgis) leading to server crash  (Roman Cervenak <roman@cervenak.info>)
Responses Re: Memory leak (possibly connected to postgis) leading to server crash
List pgsql-bugs
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



pgsql-bugs by date:

Previous
From: Roman Cervenak
Date:
Subject: Re: Memory leak (possibly connected to postgis) leading to server crash
Next
From: kjonca@fastmail.com (Kamil Jońca)
Date:
Subject: Re: Random crashes - segmentation fault