[vtkusers] VTK not releasing memory, including minimal example.

P.J.Schaafsma jetze.schaafsma at gmail.com
Sun Sep 23 09:57:52 EDT 2012


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
GetOutputPort/SetInputConnection)

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()
render_window.AddRenderer(renderer)

interactor = vtk.vtkRenderWindowInteractor()
interactor.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
interactor.SetRenderWindow(render_window)
interactor.Initialize()

actors = []
for i in range(1):
    reader = vtk.vtkXMLImageDataReader()
    #reader.SetFileName('e:\\data\\volume\\volume.vti')
    reader.SetFileName('/media/Data/data/volume/volume.vti')
    
    contour = vtk.vtkContourFilter()
    contour.SetValue(0, 800)
    contour.SetInputConnection(reader.GetOutputPort())
    
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputConnection(contour.GetOutputPort())
    mapper.Update()
    
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    
    renderer.AddActor(actor)
    
    actors.append(actor)

# key line #1
render_window.Render()

for actor in actors:
    renderer.RemoveActor(actor)
    interactor.UnRegister(actor)

render_window.Render()

actor.SetMapper(None)
mapper.SetInputConnection(None)
contour.SetInputConnection(None)

reader = None
contour = None
mapper = None
actor = None

# key line #2
interactor.Start()



--
View this message in context: http://vtk.1045678.n5.nabble.com/VTK-not-releasing-memory-including-minimal-example-tp5716258.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list