[vtkusers] Fwd: Memory leak

Jonathan Morra jonmorra at gmail.com
Tue Apr 10 10:29:36 EDT 2012


I do not have access to either system with a UI (I have only command line
linux).
1.  Is there anyway to test it on Windows?
2.  Can you try running it and see if you get the same memory issues?

On Tue, Apr 10, 2012 at 5:44 AM, Cory Quammen <cquammen at cs.unc.edu> wrote:

> The code you've provided looks reasonable. If you wait a while, does
> the memory usage go down eventually?
>
> Do you have access to a Linux machine or a Mac? If so, valgrind should
> show you were the memory leak is coming from.
>
> Cory
>
> On Tue, Apr 10, 2012 at 12:00 AM, Jonathan Morra <jonmorra at gmail.com>
> wrote:
> > I posted this a while ago and got no response.  Does anyone else see this
> > problem?  Is there more information that I can provide?
> >
> >
> > ---------- Forwarded message ----------
> > From: Jonathan Morra <jonmorra at gmail.com>
> > Date: Tue, Mar 27, 2012 at 8:10 AM
> > Subject: Memory leak
> > To: VTK Mailing List <vtkusers at vtk.org>
> >
> >
> > I posted this problem before, but got no response.  I've slightly
> modified
> > my test program to illustrate the problem more clearly.  Specifically,
> when
> > I run the below code on Windows 7 compiled with MSVC 2008 in 32 bit with
> Qt
> > 4.7.4 and VTK pulled from git master on March 5, 2012, I get a pretty
> > pronounced memory leak.  As I mouse over the image, then memory in the
> > Windows Task Manager climbs.  If I comment out the imageViewer->Render();
> > line then the memory stays constants.
> >
> > Can someone please
> > 1.  Verify that they see this on their machine as well
> > 2.  Provide a way to fix it.
> >
> > Thanks
> >
> > #include <QtGui/QApplication>
> >
> > #include <QMainWindow>
> >
> > #include <QVTKWidget2.h>
> >
> > #include <vtkImageViewer2.h>
> >
> > #include <vtkImageData.h>
> >
> > #include <vtkPointData.h>
> >
> > #include <vtkGenericOpenGLRenderWindow.h>
> >
> > class MyQVTKWidget2 : public QVTKWidget2 {
> >
> > public:
> >
> >     MyQVTKWidget2 (vtkImageViewer2 *imageViewer, QWidget *parent = 0) :
> > QVTKWidget2(parent) {
> >
> >         this->imageViewer = imageViewer;
> >
> >     }
> >
> >     virtual ~MyQVTKWidget2() {
> >
> >         imageViewer->Delete();
> >
> >     }
> >
> >     void mouseMoveEvent(QMouseEvent *) {
> >
> >         for (int i=0; i<1000; ++i) {
> >
> >             // Comment out these lines to see the memory stay constant
> >
> >             imageViewer->Render();
> >
> >         }
> >
> >     }
> >
> > private:
> >
> >     vtkImageViewer2 *imageViewer;
> >
> > };
> >
> > int main(int argc, char *argv[]) {
> >
> >     QApplication a(argc, argv);
> >
> >     vtkImageData *imageData = vtkImageData::New();
> >
> >     imageData->SetExtent(0, 100, 0, 100, 0, 100);
> >
> >     imageData->SetOrigin(0, 0, 0);
> >
> >     imageData->SetSpacing(1, 1, 1);
> >
> >     imageData->AllocateScalars();
> >
> >     imageData->GetPointData()->GetScalars()->FillComponent(0, 0);
> >
> >     vtkImageViewer2 *imageViewer = vtkImageViewer2::New();
> >
> >     imageViewer->SetInput(imageData);
> >
> >     MyQVTKWidget2 *widget = new MyQVTKWidget2(imageViewer);
> >
> >     imageViewer->SetRenderWindow(widget->GetRenderWindow());
> >
> >     QMainWindow mainWindow;
> >
> >     mainWindow.setGeometry(200, 200, 300, 300);
> >
> >     mainWindow.setCentralWidget(widget);
> >
> >     mainWindow.show();
> >
> >     imageData->Delete();
> >
> >     return a.exec();
> >
> > }
> >
> >
> > Here is the Qt .pro file as well if it helps
> >
> >
> > #-------------------------------------------------
> >
> >
> > #
> >
> > # Project created by QtCreator 2012-02-24T13:30:58
> >
> >
> > #
> >
> > #-------------------------------------------------
> >
> > QT       += core opengl gui
> >
> >
> >
> > TARGET = QVTKWidget2Test
> >
> > CONFIG   += console
> >
> > CONFIG   -= app_bundle
> >
> > TEMPLATE = app
> >
> >
> > SOURCES += main.cpp
> >
> > LIBS    += -L../../vtk/lib -lvtkCommon -lvtksys -lQVTK\
> >
> >
> >  -lvtkViews -lvtkWidgets -lvtkInfovis -lvtkRendering -lvtkGraphics
> > -lvtkImaging -lvtkIO -lvtkFiltering\
> >
> >
> >  -lvtklibxml2 -lvtkDICOMParser -lvtkpng -lvtkpng -lvtktiff -lvtkzlib
> > -lvtkjpeg -lvtkalglib -lvtkexpat\
> >
> >
> >  -lvtkverdict -lvtkmetaio -lvtkNetCDF -lvtksqlite -lvtkexoIIc -lvtkftgl
> > -lvtkfreetype -lvtkHybrid\
> >
> >
> >  -lvtkVolumeRendering
> >
> > INCLUDEPATH += ../vtk/include
> >
> >
> >
> >
> >
> > _______________________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Please keep messages on-topic and check the VTK FAQ at:
> > http://www.vtk.org/Wiki/VTK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
> >
>
>
>
> --
> Cory Quammen
> Research Associate
> Department of Computer Science
> The University of North Carolina at Chapel Hill
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120410/2e47f216/attachment.htm>


More information about the vtkusers mailing list