[vtkusers] VTK not releasing memory, including minimal example.
david.gobbi at gmail.com
Sun Sep 23 11:46:58 EDT 2012
The only obvious error that I found in your code was the call to UnRegister():
The above is exactly the same as calling interactor->Delete(), and I
don't think that was what you were intending to do. Really, you should
never call UnRegister(). In C++, you should call Delete(), and in
Python, you should always let Python do the GC for you (though
making sure that objects are disconnected can help).
>From looking at your code, I can't say what might be causing the
leaks, but I recommend that you try valgrind with the options
"valgrind --leak-check=full". You can also build VTK with leak
checking enabled, by setting VTK_DEBUG_LEAKS=ON in cmake.
On Sun, Sep 23, 2012 at 7:57 AM, P.J.Schaafsma
<jetze.schaafsma at gmail.com> wrote:
> The code below illustrates a problem where VTK fails to release memory. The
> amount of memory the program uses at the very end, when all actors have been
> removed and the interactor starts, grows approximately linearly with the
> number of iterations.
> It comes down to this. If I comment 'key line #1' then the eventual memory
> consumption is in the 10s of Mbs, irrespective of the number of iterations.
> Otherwise, it grows into the hundreds quickly. So at the application code
> leve,l the Render call causes the issue (hence the mapper.Update() call to
> force the pipeline to execute). The volume.vti dataset is about 8Mb on disk.
> The problem persists in many configurations. I've tested with:
> VTK 5.6.1 / VTK 5.10.0
> Win7-64 / Kubuntu 12.04-64
> Python 2.7 / C++
> RelWithDeb / Debug VTK builds.
> Pipelined / non-pipelined VTK (using Update/GetOutput/SetInput vs
> I've been working on it for quite some time now, trying many different
> solutions I found in various forum post, but of course there's a chance I've
> missed the correct one. Using the DataReleaseFlag in various ways either
> made no difference, or produced incorrect results (not showing anything in
> de render window).
> My questions:
> - Is it an issue, or is this somehow by design?
> - Am I missing crucial method calls that would cause this issue?
> - Can anyone confirm the issue?
> - What else can I try?
> The Python code
> import vtk
> renderer = vtk.vtkRenderer()
> render_window = vtk.vtkRenderWindow()
> interactor = vtk.vtkRenderWindowInteractor()
> actors = 
> for i in range(1):
> reader = vtk.vtkXMLImageDataReader()
> contour = vtk.vtkContourFilter()
> contour.SetValue(0, 800)
> mapper = vtk.vtkPolyDataMapper()
> actor = vtk.vtkActor()
> # key line #1
> for actor in actors:
> reader = None
> contour = None
> mapper = None
> actor = None
> # key line #2
More information about the vtkusers