[Insight-users] Memory leak in the MeshSource

Luis Ibanez luis.ibanez at kitware.com
Wed Dec 10 15:10:24 EST 2008


Hi Doug,


Thanks for the report,


Your code looks fine, although we don't get to see the signature
of the function from which you are returning the mesh, and how
do you use it later...



You may want to give it a try at adding a call to DisconnnectPipeline()

Something like:

 >       MeshType::Pointer mesh= meshSource->GetOutput();
 >       mesh->DisconnectPipeline();
 >       return mesh;

This may or may not do the trick.


Although, even if it does, it still indicates that something
suspicious is going on inside the MeshSource object, or with
your method of returning from the function.


---


As a sanity verification I just ran with Valgrind the example


      Insight/Examples/Filtering/SurfaceExtraction.cxx


with a 100x100x100 image containing a binary sphere of radius 40.

Valgrind didn't indicated any memory leak.

Which give us some confidence on this filter.


Although it is always possible that the particular characteristics
of your input image may be exercising a piece of the code that our
simple sphere does not, and that this particular section of the
code may have a memory leak on it.


Is there a chance that you could run this example

      Insight/Examples/Filtering/SurfaceExtraction.cxx

on your input image, and do this through Valgrind ?


    Please let us know,


       Luis


------------------
Doug Hoppes wrote:
> Hi all,
> 
>  
> 
> I’m trying to locate a memory leak in our application.  When I use the 
> following code:
> 
>  
> 
>       MeshSourceType::Pointer meshSource = MeshSourceType::New();
> 
>       meshSource->SetInput( pBinImg );
> 
>       meshSource->SetObjectValue( 1 );
> 
>       meshSource->Update();
> 
>       MeshType::Pointer mesh= meshSource->GetOutput();
> 
>       return mesh;
> 
>  
> 
> I get a memory leak at the meshSource->Update() method.  The error is:
> 
>  
> 
> {1506387} normal block at 0x0555CFF8, 0 bytes long.
> 
>  Data: <> €û_
> 
>  
> 
> If I don’t do the meshSource->Update(), then there are no leaks.  Since 
> I create the Meshsource, update it and then return it immediately, do I 
> really need to do the Update(). Is there something that I’m missing?  I 
> have the latest build of the ITK and the issue still happens.
> 
>  
> 
> Doug
> 
> ----------------------------------------------------------------------
> 
> Doug Hoppes dhoppes at mbfbioscience.com <mailto:dhoppes at mbfbioscience.com>
> 
> Senior Software Engineer
> 
> MBF Bioscience (Microbrightfield, Inc.)
> 
> +1.802.288.9290 ext: 119
> 
> www.mbfbioscience.com
> 
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list