[Insight-developers] Mismatched new - free (freeing images in VTK
created by ITK)
Karthik Krishnan
karthik.krishnan at kitware.com
Thu Aug 23 12:48:09 EDT 2007
Hello,
An itk::VectorImage is passed through as a vtkImageData grabbing the
internal pointer.
Valgrind is groaning about mismatching a new with a free. The issue is that
ITK images (see itk::ImportImageContainer) allocate/deallocate memory with
"new/delete". VTK images (see vtkDataArrayTemplate) free memory with
"malloc/free". Google tells me that you may be able to get away with this on
some platforms, but it is not guarenteed to work.
Is there a solution to this or should I just be ignoring this ?
Thanks
------------------------------Mismatched free() / delete / delete []
at 0x4A2066A: free (vg_replace_malloc.c:233)
by 0x705A0FB: vtkDataArrayTemplate<short>::~vtkDataArrayTemplate() (
vtkDataArrayTemplate.txx:45)
by 0x70582C6: vtkShortArray::~vtkShortArray() ( vtkShortArray.cxx:36)
by 0x702E934: vtkObjectBase::UnRegisterInternal(vtkObjectBase*, int) (
vtkObjectBase.cxx:259)
by 0x702D704: vtkObject::UnRegisterInternal(vtkObjectBase*, int) (
vtkObject.cxx:663)
by 0x702E7A2: vtkObjectBase::UnRegister(vtkObjectBase*) (
vtkObjectBase.cxx:170)
by 0x67C8EA4: vtkFieldData::InitializeFields() (vtkFieldData.cxx:207)
by 0x67B82DE: vtkDataSetAttributes::InitializeFields() (
vtkDataSetAttributes.cxx:188)
by 0x67C8A89: vtkFieldData::Initialize() ( vtkFieldData.cxx:225)
by 0x67B82A2: vtkDataSetAttributes::Initialize() (
vtkDataSetAttributes.cxx:204)
by 0x67B8891: vtkDataSetAttributes::~vtkDataSetAttributes() (
vtkDataSetAttributes.cxx:66)
by 0x68762A6: vtkPointData::~vtkPointData() ( vtkPointData.h:38)
Address 0xCCE0120 is 0 bytes inside a block of size 270,400 alloc'd
at 0x4A20F04: operator new[](unsigned long) (vg_replace_malloc.c:199)
by 0x4F0E2EA: itk::ImportImageContainer<unsigned long,
short>::AllocateElements(unsigned long) const ( itkImportImageContainer.txx
:178)
by 0x4F0E69E: itk::ImportImageContainer<unsigned long,
short>::Reserve(unsigned long) (itkImportImageContainer.txx:79)
by 0x505E58F: itk::VectorImage<short, 3>::Allocate() ( itkVectorImage.txx
:55)
by 0x507EC8B: itk::ImageFileReader<itk::VectorImage<short, 3>,
itk::DefaultConvertPixelTraits<short> >::GenerateData() (
itkImageFileReader.txx:306)
by 0x56A3957: itk::ProcessObject::UpdateOutputData(itk::DataObject*) (
itkProcessObject.cxx:991)
by 0x56689C9: itk::DataObject::UpdateOutputData() (itkDataObject.cxx:420)
by 0x56688ED: itk::DataObject::Update() (itkDataObject.cxx:344)
by 0x56A2E65: itk::ProcessObject::UpdateLargestPossibleRegion() (
itkProcessObject.cxx:1131)
by 0x4F9C6BE:
vtkITKArchetypeImageSeriesVectorReader::ExecuteData(vtkDataObject*) (
vtkITKArchetypeImageSeriesVectorReader.cxx:158)
by 0x68BBEBA: vtkSource::ProcessRequest(vtkInformation*,
vtkInformationVector**, vtkInformationVector*) ( vtkSource.cxx:672)
by 0x67C2F9F: vtkExecutive::CallAlgorithm(vtkInformation*, int,
vtkInformationVector**, vtkInformationVector*) (vtkExecutive.cxx:747)
malloc/free: in use at exit: 0 bytes in 0 blocks.
malloc/free: 17,780 allocs, 17,780 frees, 2,159,088 bytes allocated.
All heap blocks were freed -- no leaks are possible.
--------------------
Karthik Krishnan
R&D Engineer,
Kitware Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.itk.org/mailman/private/insight-developers/attachments/20070823/6786df6e/attachment.htm
More information about the Insight-developers
mailing list