Added to TODO:

o Fix memory leak from exceptions$


Tom Lane wrote:
"jody brownell" <> writes:
INSERT into attacker_target_link (attacker_id, target_id) values (p_attacker, v_target);
v_returns_size := v_returns_size + 1;
v_returns[v_returns_size] := v_target;
EXCEPTION WHEN unique_violation THEN
-- do nothing... app cache may be out of date.
Hmm. There is a known problem that plpgsql leaks some memory when
catching an exception:

So if your problem case involves a whole lot of duplicates then that
could explain the initial bloat. However, AFAIK that leakage is in
a transaction-local memory context, so the space ought to be freed at
transaction end. And Linux's malloc does know about giving space back
to the kernel (unlike some platforms). So I'm not sure why you're
seeing persistent bloat.

Can you rewrite the function to not use an EXCEPTION block (perhaps
a separate SELECT probe for each row --- note this won't be reliable
if there are concurrent processes making insertions)? If so, does
that fix the problem?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?
Bruce Momjian

+ If your life is a hard drive, Christ can be your backup. +

Search Discussions

Discussion Posts


Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 11 of 11 | next ›
Discussion Overview
grouppgsql-performance @
postedJun 14, '06 at 7:30p
activeJun 15, '06 at 5:18p



site design / logo © 2018 Grokbase