[vtkusers] Memory leak with wxVTKRenderWindow? Please help.

Charl P. Botha c.p.botha at its.tudelft.nl
Tue May 6 09:18:03 EDT 2003


On Tue, 2003-05-06 at 14:35, Marcus Stojek wrote:
> I am using vtk40 with Python 2.2 and wxPython on Windows NT.
> The software I am working on is a kind of viewer for simulation
> results. When opening and closing one result files and viewing
> it with vtk repeatedly, the memory usage increases with each new widget I
> create. The memory isn't returned to the system when the widget is
> destroyed. Even for small modells with only 10 or 15 triangles I am
> loosing app 5M of memory with each widget.
> 
> The example code below should demonstrate the problem. Either click
> 'Generate Data' once and then 'Render Data' and 'CloseRenderWindow'
> alternately for several times. Or just create a widget without data
> and renderer and then close it for several times ('MakeWidget' and
> 'CloseRenderWindow').
> 
> Watch the output or your Taskmanager for memory usage.
> 
> Is there something wrong with the wxVTKRenderWindow?
> Or with my code?

If there is ANY python binding to ANY object which has the remotest
indirect reference to the renderer or renderwindow,  the Rendererer and
RenderWindow won't be destroyed.  This is the reference counting at
work.

Call the DebugOn() method of both your renderer and renderwindow each
time so that you can see if the thing actually self-destructs when it
should.  If it's not, it means you have a direct/indirect reference
hanging somewhere.

Your Destroy() on the wxVTKRenderWindow is also not the best thing to
do: the RenderWindow might still be alive when you do that.  At the
moment, one of the ways to take care of this is to call WindowRemap() on
the RenderWindow contained by the wxVTKRenderWindow.  Only then can you
call Destroy on the containing wxVTKRenderWindow.

I am working on a new API call for the vtkRenderWindow which should
alleviate these problems in the future.

Thanks,
Charl

-- 
charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/



More information about the vtkusers mailing list