[vtkusers] vtkImageViewer memory usage

Suresh Joshi sureshj at gmail.com
Fri May 27 15:06:34 EDT 2011


Hello all,

I've done a fair bit of Googling, but haven't found many topics about this.

In most of my applications dealing with ITK/VTK, I haven't cared too
much about the memory used by the viewer, because I'd usually also
have a 3D volumetric reconstruction/registration running at the same
time, but for the first time I've taken note of the memory used by the
viewer window itself.

In a naive application (in C++ usually, but for instance in python here):
*******
reader = vtkJPEGReader()
# 27kb JPEG file
reader.SetFileName( "Albert-Einstein.jpg" )
reader.Update()

viewer = vtkImageViewer()
viewer.SetInputConnection( read.GetOutputPort() )

interactor = vtkRenderWindowInteractor()
viewer.SetupInteractor( interactor )

viewer.Render()
interactor.Start()
*******

This 'program' seems to use about 50MB of memory on my Windows 7 box
(with VTK 5.6). When I place these viewers (in c++) in my
applications, I notice a similar usage...

Now, the problem for me this time is that I need a less
memory-intensive viewer, because I would like to instantiate multiple
(lets say at least 10) vtkImageViewers in my app (yet, greedily, I
would like to keep similar functionality, with interactions and all).

So I guess I have a few questions:
a) Is there any documentation anywhere discussing the memory
footprints of the vtk viewers/viewports/windows/etc and discussing the
best practices when it comes to keeping memory usage down?
b) Is my naive approach of creating multiple vtkImageViewers the worst
thing I can do (keeping in mind that it gives the exact functionality
that I desire right now)?
c) Should I be looking at having one renderWindow with multiple
viewports instead, with one or more interactors? (And is this
noticeably better?)

Thanks everyone!
-SJ



More information about the vtkusers mailing list