Skip site navigation (1) Skip section navigation (2)

Re: plpython memory leak uppon empty resultsets in all versions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-bugs(at)postgresql(dot)org, Peter Eisentraut <peter_e(at)gmx(dot)net>
Subject: Re: plpython memory leak uppon empty resultsets in all versions
Date: 2010-04-30 18:09:48
Message-ID: 12857.1272650988@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
Andres Freund <andres(at)anarazel(dot)de> writes:
> On Friday 30 April 2010 19:39:32 Tom Lane wrote:
>> Yeah.  There's a leak of the tuptable in the CATCH path, too.  Will fix.

> Yes, theres even more than that (measured it) in the error case. Will have a 
> look later today.

Here's the patch I'm planning to apply --- working it back into the
back branches now.

			regards, tom lane


Index: plpython.c
===================================================================
RCS file: /cvsroot/pgsql/src/pl/plpython/plpython.c,v
retrieving revision 1.141
diff -c -r1.141 plpython.c
*** plpython.c	18 Mar 2010 19:43:03 -0000	1.141
--- plpython.c	30 Apr 2010 17:38:20 -0000
***************
*** 3147,3155 ****
  
  					PyList_SetItem(result->rows, i, row);
  				}
- 				PLy_typeinfo_dealloc(&args);
- 
- 				SPI_freetuptable(tuptable);
  			}
  		}
  		PG_CATCH();
--- 3147,3152 ----
***************
*** 3160,3170 ****
  			if (!PyErr_Occurred())
  				PLy_exception_set(PLy_exc_error,
  					   "unrecognized error in PLy_spi_execute_fetch_result");
- 			Py_DECREF(result);
  			PLy_typeinfo_dealloc(&args);
  			return NULL;
  		}
  		PG_END_TRY();
  	}
  
  	return (PyObject *) result;
--- 3157,3171 ----
  			if (!PyErr_Occurred())
  				PLy_exception_set(PLy_exc_error,
  					   "unrecognized error in PLy_spi_execute_fetch_result");
  			PLy_typeinfo_dealloc(&args);
+ 			SPI_freetuptable(tuptable);
+ 			Py_DECREF(result);
  			return NULL;
  		}
  		PG_END_TRY();
+ 
+ 		PLy_typeinfo_dealloc(&args);
+ 		SPI_freetuptable(tuptable);
  	}
  
  	return (PyObject *) result;

In response to

Responses

pgsql-bugs by date

Next:From: Andres FreundDate: 2010-04-30 21:54:16
Subject: Re: plpython memory leak uppon empty resultsets in all versions
Previous:From: Andres FreundDate: 2010-04-30 17:57:36
Subject: Re: plpython memory leak uppon empty resultsets in all versions

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group