From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15321: XMLTABLE leaks memory like crazy
Date: Sat, 11 Aug 2018 01:28:47 +0100
Message-ID: <87va8h7nyl.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <153394403528.10284.7530399040974170549@wrigleys.postgresql.org>
References: <153394403528.10284.7530399040974170549@wrigleys.postgresql.org>
>>>>> "PG" == PG Bug reporting form <noreply@postgresql.org> writes:
PG> From a report on IRC:
PG> XMLTABLE runs a lot of setup code in the per-query memory context -
PG> resulting in allocations of copies of namespace names, other
PG> values, and _multiple copies of the passed-in XML document_, which
PG> are not freed anywhere.
Alvaro, I think this comment of yours from when you committed this work
is relevant:
>> I just pushed XMLTABLE, after some additional changes. Please test
>> it thoroughly and report any problems.
[...]
>> Some changes I made:
>> * I removed the "buildercxt" memory context. It seemed mostly
>> pointless, and I was disturbed by the MemoryContextResetOnly().
>> Per-value memory still uses the per-value memory context, but the
>> rest of the stuff is in the per-query context, which should be
>> pretty much the same.
A quick reading suggests that the per-value context should have been
changed to not be a child of "buildercxt" (which would avoid the
MemoryContextResetOnly issue - that's a good sign that you've put a
child context under the wrong parent). But the use of the per-query
context instead is exactly what causes this blowup; compare with what
nodeFunctionscan does with its "argcontext" (and the corresponding
comments in ExecMakeTableFunctionResult).
--
Andrew (irc:RhodiumToad)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: andrew@tao11.riddles.org.uk, alvherre@2ndquadrant.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15321: XMLTABLE leaks memory like crazy
In-Reply-To: <87va8h7nyl.fsf@news-spur.riddles.org.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox