Memory leak in my extention

Michael Hudson mwh at python.net
Thu Nov 22 11:52:43 CET 2001


jf.richard at videotron.ca (Jean-Francois Richard) writes:

> I am trying to export a c function that build a tuple and return it to
> python, everything is working perfectly except that it leak like hell
> :(
> 
> It is the first time I write a python extention and I can not seem to
> find the method to do it right!
> 
> Here is a code snippet:
> 
>         int minx, miny, minz, maxx, maxy, maxz;
>         Font->BBox(text.c_str(), minx, miny, minz, maxx, maxy, maxz);
>         
>         PyObject* result = Py_BuildValue("((iii) (iii))", 
>             minx, miny, minz, 
>             maxx, maxy, maxz);
>         
>         return result;
> 
> What have I forgotten??

To include the code that causes the leak?  That looks fine to me.  Are
you sure you're leaking Python objects?

Cheers,
M.

-- 
  > Emacs is a fashion statement.
  No, Gnus is a fashion statement.  Emacs is clothing.  Everyone 
  else is running around naked.
        -- Karl Kleinpaste & Jonadab the Unsightly One, gnu.emacs.gnus



More information about the Python-list mailing list