From: | Lauri Laanmets <pcspets(at)gmail(dot)com> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Memory leak on subquery as scalar operand |
Date: | 2022-10-30 17:13:36 |
Message-ID: | CAPH-tTxLf44s3CvUUtQpkDr1D8Hxqc2NGDzGXS1ODsfiJ6WSqA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
There seems to be a memory leak in PostgreSQL for Linux (doesn't happen on
Windows). At least in versions 12 to 14 (and not in 9.5). It can be
reproduced with the following SQL script on an empty database.
* When repeated, Linux process starts using more and more RAM until
OOM-killer will kill it.
* 'pg_backend_memory_contexts' doesn't show any increase.
* (gdb) p MemoryContextStats(TopMemoryContext) - doesn't show any increase.
-/
CREATE TABLE IF NOT EXISTS public.leak_test
(
id integer NOT NULL,
CONSTRAINT leak_test_pkey PRIMARY KEY (id)
);
INSERT INTO leak_test(id)
SELECT id
FROM generate_series(1,100000) id
ON CONFLICT DO NOTHING;
SELECT
id,
(SELECT count(*) FROM leak_test x WHERE x.id=l.id) as x_result,
(SELECT count(*) FROM leak_test y WHERE y.id=l.id) as y_result
/* Leaks memory around 80 kB on each query, but only if two sub-queries
are used. */
FROM leak_test l;
/-
Regards
Lauri
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-10-30 17:57:37 | Re: Problem with Avg function and Money type in PostgreSQL 15 |
Previous Message | Japin Li | 2022-10-30 13:52:26 | Re: BUG #17670: Logical Replication data may be lost on the subscription under certain scenarios |