[Zodb-checkins] CVS: Zope3/src/zodb/btrees - BTreeTemplate.c:1.11

Tim Peters tim.one@comcast.net
Tue, 18 Mar 2003 17:30:46 -0500


Update of /cvs-repository/Zope3/src/zodb/btrees
In directory cvs.zope.org:/tmp/cvs-serv1336/src/zodb/btrees

Modified Files:
	BTreeTemplate.c 
Log Message:
BTree_newBucket():  This leaked a reference to the bucket-construction
function (like OOBucket).  The patch fixes 1 leaking reference per
iteration of a test program I have, leaving about 108 leaking refs per
iteration.  So far, I haven't even been able to figure out what kinds
of objects are the leak beneficiaries, except to note that they're
probably static type objects (like OOBucket) since in a Python debug-build
the leaks do reflect in sys.gettotalrefcount() but not in the sum of
sys.getrefcount(x) across all x in sys.getobjects(0) (and, AFAIK, only
static type objects don't show up in the sys.getobjects(0) list).


=== Zope3/src/zodb/btrees/BTreeTemplate.c 1.10 => 1.11 ===
--- Zope3/src/zodb/btrees/BTreeTemplate.c:1.10	Tue Mar  4 17:36:53 2003
+++ Zope3/src/zodb/btrees/BTreeTemplate.c	Tue Mar 18 17:30:45 2003
@@ -233,8 +233,9 @@
 BTree_newBucket(BTree *self)
 {
     PyObject *factory;
-    /* _bucket_type_str defined in BTreeModuleTemplate.c */
+    Sized *result;
 
+    /* _bucket_type_str defined in BTreeModuleTemplate.c */
     factory = PyObject_GetAttr((PyObject *)self->ob_type, _bucket_type_str);
     if (factory == NULL)
 	return NULL;
@@ -243,7 +244,9 @@
        depend on any custom bucket type having the same layout at the
        C level.
     */
-    return (Sized *)PyObject_CallObject(factory, NULL);
+    result = SIZED(PyObject_CallObject(factory, NULL));
+    Py_DECREF(factory);
+    return result;
 }
 
 /*