[Insight-users] possible mismatched free()/delete/delete[] ?

Feng Ma mafeng at hotmail.com
Tue, 23 Mar 2004 14:34:18 -0500


Hi,

  I met the "Mismatched free() / delete / delete []" in valgrind output of 
my code:

  watershed = itk::WatershedImageFilter<InternalImageType>::New();
  watershed->SetThreshold(lowerThreshold);
  watershed->SetLevel(maxFloodLevel);
  watershed->SetInput(magnitude->GetOutput());
  watershed->UpdateLargestPossibleRegion();

  The valgrind output is:

==22333==
==22333== Mismatched free() / delete / delete []
==22333==    at 0x40027C07: __builtin_delete (vg_replace_malloc.c:233)
==22333==    by 0x40B8718F: itk::EquivalencyTable::~EquivalencyTable(void) 
(in /usr/lib/InsightToolkit/libITKCommon.so)
==22333==    by 0x40B90A0E: itk::LightObject::UnRegister(void) const (in 
/usr/lib/InsightToolkit/libITKCommon.so)
==22333==    by 0x40B97B40: itk::Object::UnRegister(void) const (in 
/usr/lib/InsightToolkit/libITKCommon.so)
==22333==    Address 0x469E2F14 is 0 bytes inside a block of size 92 alloc'd
==22333==    at 0x40027894: malloc (vg_replace_malloc.c:153)
==22333==    by 0x822466C: __builtin_new (in /home/fma/test/main)
==22333==    by 0x81CAC98: itk::EquivalencyTable::New(void) 
(/usr/include/InsightToolkit/Common/itkEquivalencyTable.h:55)
==22333==    by 0x81B34A9: itk::watershed::Segmenter<itk::Image<float, 3> 
 >::LabelMinima(itk::SmartPointer<itk::Image<float, 3> >, 
itk::ImageRegion<3>, itk::hash_map<unsigned long, 
itk::watershed::Segmenter<itk::Image<float, 3> >::flat_region_t, 
itk::hash<unsigned long>, equal_to<unsigned long>, allocator<char> > &, 
float) 
(/usr/include/InsightToolkit/Algorithms/itkWatershedSegmenter.txx:636)

  I know that itkNewMacro() use new operator. But somehow, it eventually 
ends up with malloc().
I am using ITK1.4.0. The ITK libraries were dynamic libraries.

  Interesting thing is: I have another project with same code and ITK 
compiled as static libraries, I didn't see this error.

  Any hints?

  Thanks a lot.

-Feng

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar – get it now! 
http://clk.atdmt.com/AVE/go/onm00200415ave/direct/01/