ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> pyxpcom
pyxpcom
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved