Unix Technical Forum

plpython: fix memory leak

This is a discussion on plpython: fix memory leak within the Pgsql Patches forums, part of the PostgreSQL category; --> Attached is a patch that fixes three Python reference leaks in PLy_traceback(): the objects returned by PyErr_Fetch() are owned ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 01:22 AM
Neil Conway
 
Posts: n/a
Default plpython: fix memory leak

Attached is a patch that fixes three Python reference leaks in
PLy_traceback(): the objects returned by PyErr_Fetch() are owned by the
caller, so their reference count should be decremented. The memory leak
can be reproduced as follows:

create function import_fail() returns text as
'import foosocket
return "succeeded, that wasn''t supposed to happen"'
LANGUAGE plpythonu;

create function test_py() returns void as $$
begin
for i in 1 .. 1000 loop
perform import_fail();
end loop;
return;
end;$$ language plpgsql;

select test_py();

On my system, each invocation of test_py() leaks about 2MB. With the
patch applied, each invocation leaks about 500KB. So obviously there are
some more leaks here -- I searched briefly for additional problems, but
couldn't see anything obvious.

I don't have time at the moment to track down the remaining problems, so
I'd like to apply the patch as-is: I'll come back to the remaining
memory leaks later, unless someone beats me to it.

Barring any objections, I'll apply this patch to HEAD and back branches
tomorrow.

-Neil



---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-18-2008, 01:22 AM
Neil Conway
 
Posts: n/a
Default Re: plpython: fix memory leak

On Sun, 2006-02-19 at 20:34 -0500, Neil Conway wrote:
> Attached is a patch that fixes three Python reference leaks in
> PLy_traceback(): the objects returned by PyErr_Fetch() are owned by the
> caller, so their reference count should be decremented.


Applied to HEAD and back branches. I also noticed a minor bug in
PLy_modify_tuple(): we don't own a reference to `platt', so we shouldn't
try to decrement its refcount. I only bothered fixing the latter bug in
8.0+

-Neil



---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:22 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com