From: schaerer Date: Wed, 4 Aug 2010 16:15:51 +0000 (+0000) Subject: attempt to fix some leaks. Note that vv still leaks: memory is never given back to... X-Git-Tag: v1.2.0~443 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=ffa30ffca0e90ece637fadde1f3dd65166f20ab4;p=clitk.git attempt to fix some leaks. Note that vv still leaks: memory is never given back to the OS when an image is closed --- diff --git a/common/vvFromITK.h b/common/vvFromITK.h index 8187051..fb1e882 100644 --- a/common/vvFromITK.h +++ b/common/vvFromITK.h @@ -80,7 +80,7 @@ template vvImage::Pointer vvImageFromITK(type return vv_image; } vtkImageData *image = vtkImageData::New(); - image->DeepCopy(connector->GetOutput()); + image->ShallowCopy(connector->GetOutput()); vv_image->AddImage(image); } vv_image->SetTimeSpacing(input->GetSpacing()[Dim-1]); @@ -102,7 +102,7 @@ template vvImage::Pointer vvImageFromITK(type return vv_image; } vtkImageData *image = vtkImageData::New(); - image->DeepCopy(connector->GetOutput()); + image->ShallowCopy(connector->GetOutput()); vv_image->AddImage(image); } return vv_image; diff --git a/common/vvImage.cxx b/common/vvImage.cxx index 55a56ef..4675cf5 100644 --- a/common/vvImage.cxx +++ b/common/vvImage.cxx @@ -50,6 +50,7 @@ void vvImage::Init() //-------------------------------------------------------------------- vvImage::~vvImage() { + DD("vvImage got deleted!"); Reset(); } //-------------------------------------------------------------------- diff --git a/itk/itkImageToVTKImageFilter.txx b/itk/itkImageToVTKImageFilter.txx index 5bce506..25fcf7c 100644 --- a/itk/itkImageToVTKImageFilter.txx +++ b/itk/itkImageToVTKImageFilter.txx @@ -65,6 +65,10 @@ ImageToVTKImageFilter m_Importer->Delete(); m_Importer = 0; } + if ( m_Exporter ) { + m_Exporter->Delete(); + m_Exporter = 0; + } } diff --git a/vv/vvImageReader.txx b/vv/vvImageReader.txx index fd1c575..d0247fe 100644 --- a/vv/vvImageReader.txx +++ b/vv/vvImageReader.txx @@ -100,8 +100,9 @@ void vvImageReader::UpdateWithDimAndInputPixelType() std::cerr << "Error while setting vvImage from ITK (MERGEDWITHTIME)" << " " << err << std::endl; } - vtkImageData *image = vtkImageData::New(); - image->DeepCopy(connector->GetOutput()); + //vtkImageData *image = vtkImageData::New(); + //image->ShallowCopy(connector->GetOutput()); + vtkImageData *image = connector->GetOutput(); mImage->AddImage(image); } } else {