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 1gssVf-0004N9-GF for pgsql-bugs@arkaria.postgresql.org; Sun, 10 Feb 2019 17:03:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gssVd-0008FB-UC for pgsql-bugs@arkaria.postgresql.org; Sun, 10 Feb 2019 17:03:13 +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 1gssVd-0008F4-OL for pgsql-bugs@lists.postgresql.org; Sun, 10 Feb 2019 17:03:13 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gssVa-00024y-Mq for pgsql-bugs@lists.postgresql.org; Sun, 10 Feb 2019 17:03:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x1AH37fe025172; Sun, 10 Feb 2019 12:03:07 -0500 From: Tom Lane To: icegood1980@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15627: libpq memory leak In-reply-to: <15627-292cee37a2b87e13@postgresql.org> References: <15627-292cee37a2b87e13@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Sun, 10 Feb 2019 16:30:29 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25170.1549818187.1@sss.pgh.pa.us> Date: Sun, 10 Feb 2019 12:03:07 -0500 Message-ID: <25171.1549818187@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > PQisBusy has memory leak with next valgrind stack: > 1: malloc in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so > 2: PQmakeEmptyPGresult in > /opt/src/postgres/src/interfaces/libpq/fe-exec.c:146 > 3: getRowDescriptions in > /opt/src/postgres/src/interfaces/libpq/fe-protocol3.c:492 > 4: pqParseInput3 in > /opt/src/postgres/src/interfaces/libpq/fe-protocol3.c:293 > 5: parseInput in /opt/src/postgres/src/interfaces/libpq/fe-exec.c:1747 > 6: PQisBusy in /opt/src/postgres/src/interfaces/libpq/fe-exec.c:1764 I don't believe this is actually a leak: what is happening is that we're collecting the query result that will eventually be returned by PQgetResult. If the calling program never calls PQgetResult after PQisBusy, then tools like valgrind might claim that's a leak, but the claim has nothing to do with reality. If you think there's a real problem here, please show a self-contained test case that causes steady increase in memory consumption. regards, tom lane