[Numpy-discussion] memory not being freed

Paul F Dubois paul at pfdubois.com
Fri Feb 22 17:29:06 CST 2002


You just want ret = (PyObject*) arr;

I assume it is PyObject *foo() and you just didn't show it.

-----Original Message-----
From: numpy-discussion-admin at lists.sourceforge.net
[mailto:numpy-discussion-admin at lists.sourceforge.net] On Behalf Of
Mathew Yeates
Sent: Friday, February 22, 2002 4:19 PM
To: numpy-discussion at lists.sourceforge.net
Subject: [Numpy-discussion] memory not being freed



Hi
I'm having problems with garbage collection
I wrote an extension which creates an array
and returns it

foo() {
arr = (PyArrayObject *) PyArray_FromDims( .....
ret = Py_BuildValue("O", arr);
return ret;
}


but now if I do
while 1:
	a=foo()



memory is never free'd. I've even tried explicitly calling gc.collect
and adding del(a) after a=foo.

Is the problem that Py_BuildValue increases the reference count?

Mathew


_______________________________________________
Numpy-discussion mailing list Numpy-discussion at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion





More information about the Numpy-discussion mailing list