View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0010843VTK(No Category)public2010-06-17 04:322010-06-21 09:59
ReporterWallance Lin 
Assigned ToFrançois Bertel 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionwon't fix 
PlatformOSWindows XPOS VersionSP3
Product Version 
Target VersionFixed in Version 
Summary0010843: When freeing GPUVolumeRayCastMapper, the Memory leak happed.....
DescriptionWhen using and releasing GPUVolumeRayCastMapper,the Memory leak will happen. Otherwise, I found that the number of the memory leak will be determined by the size of renderWindow. If I enlarge the renderWindow, the number will increase and vice versa. However, when using vtkPixelPointVolumeRayCastMapper with the same test code, the phenomenon will not appear.

Is it a bug??
Thanks.......
TagsNo tags attached.
Project
Type
Attached Filescxx file icon TestGPURayCastFourComponentsComposite.cxx [^] (4,127 bytes) 2010-06-21 09:52

 Relationships

  Notes
(0021087)
François Bertel (developer)
2010-06-18 10:16

Please provide a minimal example to reproduce the memory leak.
(0021102)
Wallance Lin (reporter)
2010-06-20 23:51
edited on: 2010-06-20 23:54

The above example will produce the memory leak.
However, when using vtkFixedPointVolumeRayCastMapper, the memory leak will not show.

int TestGPURayCastFourComponentsComposite()
{
    vtkRenderer *ren1 = vtkRenderer::New();
    vtkRenderWindow *renWin = vtkRenderWindow::New();
    renWin->AddRenderer(ren1);
    renWin->SetSize(601,600);
    vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
    vtkInteractorStyleSwitch *iass = dynamic_cast<vtkInteractorStyleSwitch*>
                                    (iren->GetInteractorStyle());
    iass->SetCurrentStyleToTrackballCamera();
    iren->SetRenderWindow(renWin);
    renWin->Render();

    vtkXMLImageDataReader *reader = vtkXMLImageDataReader::New();
    reader->SetFileName("vase_4comp.vti");

    vtkOpenGLGPUVolumeRayCastMapper *volumeMapper;
// vtkFixedPointVolumeRayCastMapper *volumeMapper;
    vtkVolumeProperty *volumeProperty;
    vtkVolume *volume;

    volumeMapper = vtkOpenGLGPUVolumeRayCastMapper::New();
// volumeMapper = vtkFixedPointVolumeRayCastMapper::New();
    volumeMapper->SetBlendModeToComposite();
    volumeMapper->SetInputConnection(reader->GetOutputPort());

    vtkPiecewiseFunction *opacity = vtkPiecewiseFunction::New();
    opacity->AddPoint(0,0);
    opacity->AddPoint(255,1);

    volumeProperty = vtkVolumeProperty::New();
    volumeProperty->IndependentComponentsOff();
    volumeProperty->SetInterpolationTypeToLinear();
    volumeProperty->ShadeOff();
    volumeProperty->SetScalarOpacity(opacity);

    volume = vtkVolume::New();
    volume->SetMapper(volumeMapper);
    volume->SetProperty(volumeProperty);
    ren1->AddViewProp(volume);

    int valid = true;//volumeMapper->IsRenderSupported(renWin,volumeProperty);

    int retVal;
    if (valid) {
    ren1->SetBackground(0.1,0.4,0.2);
    ren1->ResetCamera();
    renWin->Render();
/* iren->Initialize();
    iren->Start(); //*/
       for (int i=0; i<10; i) {
             Sleep(10000);
             volumeMapper->Delete();
             volumeMapper = vtkOpenGLGPUVolumeRayCastMapper::New();
// volumeMapper = vtkFixedPointVolumeRayCastMapper::New();
             volumeMapper->SetBlendModeToComposite();
             volumeMapper->SetInputConnection(reader->GetOutputPort());
             volume->SetMapper(volumeMapper);
             ren1->ResetCamera();
             renWin->Render();
         } //*/
    } else {
        retVal = vtkTesting::PASSED;
        cout << "Required extensions not supported." << endl;
    }

    volumeMapper->Delete();
    volumeProperty->Delete();
    volume->Delete();
    opacity->Delete();
    reader->Delete();

    iren->Delete();
    renWin->Delete();
    ren1->Delete();

    if ((retVal == vtkTesting::PASSED) || (retVal ==
                          vtkTesting::DO_INTERACTOR))
    {
        return 0;
    } else {
        return 1;
    }
}

Thank you!!

(0021105)
François Bertel (developer)
2010-06-21 09:59

Hello,

You ignored the errors on the output like:

ERROR: In VTK/Rendering/vtkShaderProgram2.cxx, line 104
vtkShaderProgram2 (0x12096cb0): a vtkShaderProgram2 object is being deleted before ReleaseGraphicsResources() has been called.

ERROR: VTK/Rendering/vtkShader2.cxx, line 109
vtkShader2 (0x120971c0): a vtkShader2 object is being deleted before ReleaseGraphicsResources() has been called.


In your code, if you add:

volumeMapper->ReleaseGraphicsResources(renWin);

before

 volumeMapper->Delete();

There will be no leak.


BTW, you don't increment "i" in your loop.

I corrected your code. See the attachment.

Also, vtkOpenGLGPUVolumeRayCastMapper did not have ReleaseGraphicsResources() in its public section (but it superclass did). I fixed that in the repository.

Regards.

 Issue History
Date Modified Username Field Change
2010-06-17 04:32 Wallance Lin New Issue
2010-06-18 10:15 François Bertel Status backlog => tabled
2010-06-18 10:15 François Bertel Assigned To => François Bertel
2010-06-18 10:16 François Bertel Note Added: 0021087
2010-06-18 10:16 François Bertel Status tabled => @20@
2010-06-20 23:52 Wallance Lin Note Added: 0021102
2010-06-20 23:54 Wallance Lin Note Edited: 0021102
2010-06-21 09:52 François Bertel File Added: TestGPURayCastFourComponentsComposite.cxx
2010-06-21 09:59 François Bertel Note Added: 0021105
2010-06-21 09:59 François Bertel Status @20@ => closed
2010-06-21 09:59 François Bertel Resolution open => won't fix
2011-06-16 13:11 Zack Galbreath Category => (No Category)


Copyright © 2000 - 2018 MantisBT Team