[vtk-developers] Python wrappers are leaking

David Gobbi dgobbi at imaging.robarts.ca
Sat Nov 30 22:28:34 EST 2002


Hi Andy,

This leak is because the hash tables that vtk-python uses for
linking python-level and C++-level VTK objects are never deleted.
For a typical python-vtk application this is nothing to worry
about, because the leak happens only once per run and the memory
will go back to the system as part of the usual exit() cleanup.

I've hopefully fixed the leak by adding a Py_AtExit()
callback that frees the hash tables.

 - David


On 29 Nov 2002, Andy Cedilnik wrote:

> Hi All,
>
> (David)
>
> Python wrappers are leaking. Not the wrapping process itself, but the
> wrapped classes that are created. For example:
>
> PYTHONPATH=/home/andy/vtk/VTK/Wrapping/Python:/home/andy/vtk/VTK-gcc/bin
> /usr/bin/python
> Python 2.1.3 (#1, Jul 29 2002, 22:34:51)
> [GCC 2.95.4 20011002 (Debian prerelease)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> import vtk
> >>>
> vtkDebugLeaks has detected LEAKS!
> Class vtkHashMap has 2 instances still around.
> Class vtkVector has 778 instances still around.
>
> This is using debug leaks. I tried creating some objects:
>
> Python 2.1.3 (#1, Jul 29 2002, 22:34:51)
> [GCC 2.95.4 20011002 (Debian prerelease)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> import vtk
> >>> def foo():
> ...   a = vtk.vtkActor()
> ...   print a
> ...
> >>> foo()
> vtkOpenGLActor (0x810f9a8)
>   Debug: Off
>   Modified Time: 2
>   Reference Count: 2
>   Registered Events: (none)
>   Dragable: On
>   Pickable: On
>   AllocatedRenderTime: 10
>   EstimatedRenderTime: 0
>   NumberOfConsumers: 0
>   RenderTimeMultiplier: 1
>   Visibility: On
>   IsIdentity: true
>   Position: (0, 0, 0)
>   Orientation: (0, 0, 0)
>   Origin: (0, 0, 0)
>   Scale: (1, 1, 1)
>   Bounds:
>     Xmin,Xmax: (-1, 1)
>     Ymin,Ymax: (-1, 1)
>     Zmin,Zmax: (-1, 1)
>   UserTransform: (none)
>   UserMatrix: (none)
>   Mapper: (none)
>   Property: (none)
>   Texture: (none)
>
>
> >>>
> vtkDebugLeaks has detected LEAKS!
> Class vtkHashMap has 2 instances still around.
> Class vtkVector has 778 instances still around.
>
> And you can see, no leak of actor.
> So, could somebody look at the map of objects why is it not getting
> deleted?
>
> 				Andy
>
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at public.kitware.com
> http://public.kitware.com/mailman/listinfo/vtk-developers
>




More information about the vtk-developers mailing list