Re: [pyxpcom] memory leak in PyIClassInfo.cpp
by Mark Hammond other posts by this author
Jul 10 2007 10:25PM messages near this date
view in the new Beta List Site
[pyxpcom] memory leak in PyIClassInfo.cpp
|
[pyxpcom] Python Scripting Component/PyXPCOM Interprocess Communication
It looks like you are correct! It also appears using
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY would be a better alternative to the
explicit loop-and-free, and we also need to ensure we free the memory if
creating the new tuple fails (unlikely, but possible - especially if there
are leaks :)
I'll check a fix in once I've verified it works...
Thanks,
Mark
-----Original Message-----
From: pyxpcom-bounces@[...].com
[mailto:pyxpcom-bounces@[...].com]On Behalf Of jiangweiran
Sent: Wednesday, 11 July 2007 1:42 PM
To: pyxpcom
Subject: [pyxpcom] memory leak in PyIClassInfo.cpp
Hello All:
I found some memory leak in PyIClassInfo.cpp.
in function static PyObject *PyGetInterfaces(PyObject *self, PyObject
*args)��it seems the iidArray and all iid in the array is leaking,so I add
these lines before returning:
if (ret==NULL)
return NULL;
for (PRUint32 i=0;i<iidCount;i++)
PyTuple_SET_ITEM( ret, i, Py_nsIID::PyObjectFromIID(*(iidArray[i])) );
//freeing iid in the array and array itself
+ for (PRUint32 i=0;i<iidCount;i++)
+ nsMemory::Free(iidArray[i]);
+ nsMemory:Free(iidArray);
return ret;
can anyone confirm this fixes?thanks
----------------------------------------------------------------------------
--
jiangweiran
2007-07-11
Thread:
Jiangweiran
Mark Hammond
|