Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1073 [python] Memory leak using directors and vtable

open
nobody
python (259)
5
2011-02-19
2010-02-16
Anonymous
No

An instance of a derived director class in python will not be deleted when such an instance goes out of scope, when using vtable. This is because the method object returned by PyObject_GetAttr (in swig_get_method() in the generated wrapper code) and which is stored in the vtable holds a reference to the actual instance. When many such objects are instantiated and supposedly destroyed, it creates quite huge memory leaks.

Please consider the following minimal example that reproduce the leak
(Need to be run on linux/unix system to be able to print memory usage...)

make withoutleak
python runleaktest.py

make withleak
python runleaktest.py

Johan

Discussion


  • Anonymous
    2010-02-16

    A minimal example reproducing the bug

     
    Attachments
  • William Fulton
    William Fulton
    2010-02-27

    Removed -dirvtable from the list of optimizations options included by -O as a workaround for now.

     
  • Olly Betts
    Olly Betts
    2011-02-19

    • summary: Memory leak using directors and vtable --> [python] Memory leak using directors and vtable