[pyicu-dev] Memory Leak?

Andi Vajda vajda at osafoundation.org
Fri Mar 10 10:25:48 PST 2006


On Fri, 10 Mar 2006, David Bolen wrote:

> I've just begun experimenting with PyICU and I'm seeing what appear to
> be some pretty significant memory leaks, so much so that I'm guessing
> I may just be doing something very wrong.  I was wondering if anyone
> might have some suggestions as to what it is.
>
>  ... snip ...
>
> Interestingly, swig 1.3.28 generates warnings during compilation
> (about the use of the -nodefault option) and runtime such as:
>
> Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from PyICU import Locale
>>>> l = Locale('en_US')
>>>> l = Locale('en_US')
> swig/python detected a memory leak of type 'icu::Locale *', no destructor found.

This is the clue, apparently no destructor code was generated. Ugh.

> This continues to happen even if I replace the "-nodefault" option
> with "-nodefaultctor" and "-nodefaultdtor" as suggested by the swig
> warning during compilation.  I haven't really tried to evaluate why
> PyICU is choosing to disable constructor creation.

Actually, I tried to replace -nodefault with -nodefaultctor and rebuild all 
with swig 1.3.28 and the destructor code was generated and these warnings 
didn't appear anymore.

> Given the scale of this apparent leak, I have to imagine it would have
> been seen in other cases where it might be getting used, so I'm hoping
> I'm just doing something wrong, and would appreciate any thoughts.

Indeed. Apart from probably not rebuilding it correctly, you didn't do 
anything wrong. I, however, did something completely wrong by using -nodefault 
when what I really wanted was -nodefaultctor, that is, no constructor code 
generation by default, only generate code for constructors that I declare.

So, apparently, the fix to this is simple:

   - use -nodefaultctor instead of -nodefault
   - and use swig 1.3.28 since -nodefaultctor doesn't appear to be supported
     with swig 1.3.24

Thank you for finding and reporting this.
This is indeed a bad one !

I haven't done any other testing of PyICU with swig 1.3.28 and would 
appreciate it if you could report back about how it is working for you.
Every swig upgrade introduces a dose of unknowns...

I intend to make a new PyICU release in about two weeks or so...

Thanks again !

Andi..




More information about the pyicu-dev mailing list