<div><strong>Hi Richard,</strong></div><div> </div><div><strong>I tested on a simple version as following:</strong></div><div> </div><div>#define _CRTDBG_MAP_ALLOC<br>#include <stdlib.h><br>#include <crtdbg.h></div>
<div>#include "itkImage.h"<br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br>#include "itkReconstructionByDilationImageFilter.h"</div><div>int main()<br>{<br>
typedef unsigned char PixelType;<br> const unsigned int Dimension = 2;<br> typedef itk::Image< PixelType, Dimension > ImageType;<br> typedef itk::ImageFileReader< ImageType > ReaderType;<br> typedef itk::ImageFileWriter< ImageType > WriterType;<br>
<br> const char *inputFilenameMarker = "C:\\work\\MeVisData\\marker.tif"; <br> const char *inputFilenameMask = "C:\\work\\MeVisData\\mask.tif"; <br> //const char *outputFilename = "C:\\TYwork\\MeVisData\\ITKresult1.tif";</div>
<div> // Get marker image<br> ReaderType::Pointer reader = ReaderType::New();<br> reader->SetFileName( inputFilenameMarker ); <br> reader->Update(); <br> ImageType::Pointer markerImage = ImageType::New();<br> markerImage = reader->GetOutput();<br>
markerImage->DisconnectPipeline(); <br> </div><div> // Get mask image<br> //ReaderType::Pointer reader = ReaderType::New();<br> reader->SetFileName( inputFilenameMask ); <br> reader->Update(); <br> ImageType::Pointer maskImage = ImageType::New();<br>
maskImage = reader->GetOutput();</div><div> //filter</div><div> typedef itk::ReconstructionByDilationImageFilter<ImageType, ImageType> FilterType;<br> FilterType::Pointer filter = FilterType::New();<br> filter->SetMarkerImage(markerImage);<br>
filter->SetMaskImage(maskImage);<br> filter->Update(); <br> <br> _CrtDumpMemoryLeaks();<br>}</div><div> </div><div><strong>Memory leak is still seen. The first memory leak size is the same as the mask image.</strong></div>
<div><strong></strong> </div><div><strong>The memory leak log is as following:</strong></div><div> </div><div>Detected memory leaks!<br>Dumping objects -><br>{63766} normal block at 0x01F0DAD8, 147492 bytes long.<br> Data: < > FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF <br>
{63765} normal block at 0x01EE89B8, 4 bytes long.<br> Data: < > 00 00 00 00 <br>{63733} normal block at 0x01EE89F8, 8 bytes long.<br> Data: < W 8 > 80 57 EB 01 38 04 EC 01 <br>{63731} normal block at 0x01EE8DB8, 4 bytes long.<br>
Data: < > E0 87 EE 01 <br>{63730} normal block at 0x01EE8938, 64 bytes long.<br> Data: <, Z > 2C C5 9E 00 01 00 00 00 E8 5A C0 00 FF FF FF FF <br>{63669} normal block at 0x01EE87E0, 280 bytes long.<br>
Data: < PV > C4 BC 9E 00 01 00 00 00 50 56 C0 00 FF FF FF FF <br>{63608} normal block at 0x01EC0590, 9788 bytes long.<br> Data: <4 V > 34 96 9F 00 01 00 00 00 88 56 C0 00 FF FF FF FF <br>
{63547} normal block at 0x01EC4660, 8 bytes long.<br> Data: <l > 6C 99 EE 01 00 00 00 00 <br>{63546} normal block at 0x01EC0090, 8 bytes long.<br> Data: <P > 50 99 EE 01 00 00 00 00 <br>{63545} normal block at 0x01EE9540, 8 bytes long.<br>
Data: <T > 54 99 EE 01 00 00 00 00 <br>{63544} normal block at 0x01EE96D8, 8 bytes long.<br> Data: <8 > 38 99 EE 01 00 00 00 00 <br>{63543} normal block at 0x01EE9900, 156 bytes long.<br> Data: < x[ > 8C B4 9E 00 01 00 00 00 78 5B C0 00 FF FF FF FF <br>
{63353} normal block at 0x01EE9A78, 147492 bytes long.<br> Data: < > FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF <br>{63340} normal block at 0x01EE8770, 52 bytes long.<br> Data: <p p p > 70 87 EE 01 70 87 EE 01 70 87 EE 01 CD CD CD CD <br>
{63339} normal block at 0x01EE8728, 8 bytes long.<br> Data: <h > 68 A9 EB 01 00 00 00 00 <br>{63338} normal block at 0x01EBA968, 20 bytes long.<br> Data: <( p > 28 87 EE 01 CD CD CD CD 70 87 EE 01 00 00 00 00 <br>
{63337} normal block at 0x01EBA920, 8 bytes long.<br> Data: <$ h > 24 98 9F 00 68 A9 EB 01 ...</div><div>.......</div><div> </div><div><strong>The callback log on "{63766} normal block at 0x01F0DAD8, 147492 bytes long" is as following:</strong></div>
<div> </div><div>msvcr100d.dll!_heap_alloc_dbg_impl(unsigned int nSize, int nBlockUse, const char * szFileName, int nLine, int * errno_tmp) Line 393 C++<br> msvcr100d.dll!_nh_malloc_dbg_impl(unsigned int nSize, int nhFlag, int nBlockUse, const char * szFileName, int nLine, int * errno_tmp) Line 239 + 0x19 bytes C++<br>
msvcr100d.dll!_nh_malloc_dbg(unsigned int nSize, int nhFlag, int nBlockUse, const char * szFileName, int nLine) Line 302 + 0x1d bytes C++<br> msvcr100d.dll!malloc(unsigned int nSize) Line 56 + 0x15 bytes C++<br> msvcr100d.dll!operator new(unsigned int size) Line 59 + 0x9 bytes C++<br>
test.exe!operator new[](unsigned int count) Line 6 + 0x9 bytes C++<br> test.exe!itk::ImportImageContainer<unsigned long,unsigned char>::AllocateElements(unsigned long size) Line 178 + 0x9 bytes C++<br> test.exe!itk::ImportImageContainer<unsigned long,unsigned char>::Reserve(unsigned long size) Line 86 + 0x13 bytes C++<br>
test.exe!itk::Image<unsigned char,2>::Allocate() Line 52 C++<br> test.exe!itk::ImageSource<itk::Image<unsigned char,2> >::AllocateOutputs() Line 216 + 0x26 bytes C++<br> test.exe!itk::ReconstructionImageFilter<itk::Image<unsigned char,2>,itk::Image<unsigned char,2>,std::greater<unsigned char> >::GenerateData() Line 112 + 0x12 bytes C++<br>
test.exe!itk::ProcessObject::UpdateOutputData(itk::DataObject * __formal) Line 987 + 0x12 bytes C++<br> test.exe!itk::DataObject::UpdateOutputData() Line 420 + 0x21 bytes C++<br> test.exe!itk::ImageBase<2>::UpdateOutputData() Line 285 C++<br>
test.exe!itk::DataObject::Update() Line 344 + 0xf bytes C++<br> test.exe!itk::ProcessObject::Update() Line 615 + 0x1c bytes C++<br> test.exe!main() Line 63 + 0x23 bytes C++<br> test.exe!__tmainCRTStartup() Line 555 + 0x19 bytes C<br>
test.exe!mainCRTStartup() Line 371 C<br> kernel32.dll!75ad3c45() <br> [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll] <br> ntdll.dll!775337f5() <br> ntdll.dll!775337c8() </div>
<div> </div><div>I am new to ITK and it is really hard for me to detect where the leak is.</div><div> </div><div>Thank you!</div><div> </div><div> </div><div>Tina</div><div><br><br> </div><div class="gmail_quote">On Mon, Sep 19, 2011 at 6:12 PM, Richard Beare <span dir="ltr"><<a href="mailto:richard.beare@gmail.com">richard.beare@gmail.com</a>></span> wrote:<br>
<blockquote style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;" class="gmail_quote">Do you have minimalist version of your code that shows the leak?<br>
<br>
Line 112 is the AllocateOutputs() call, which is a standard part of<br>
most filters.<br>
<div><div></div><div class="h5"><br>
On Tue, Sep 20, 2011 at 12:21 AM, qi yang <<a href="mailto:tinaqiyang@gmail.com">tinaqiyang@gmail.com</a>> wrote:<br>
> Thanks for looking into this. I still haven't solved this issue.<br>
><br>
> The following is the memory leak log from VS2010 output:<br>
><br>
> Detected memory leaks!<br>
> Dumping objects -><br>
> {769} normal block at 0x09F40040, 1208320 bytes long.<br>
> Data: < P G P G P G P G> 00 50 C3 47 00 50 C3 47 00 50 C3 47 00 50 C3 47<br>
> Object dump complete.<br>
><br>
> Then I stopped at {769} where is the filter->update(), the call stack log is<br>
> as following:<br>
><br>
> msvcr100d.dll!_heap_alloc_dbg_impl(unsigned int nSize, int nBlockUse, const<br>
> char * szFileName, int nLine, int * errno_tmp) Line 393 C++<br>
> msvcr100d.dll!_nh_malloc_dbg_impl(unsigned int nSize, int nhFlag, int<br>
> nBlockUse, const char * szFileName, int nLine, int * errno_tmp) Line 239 +<br>
> 0x19 bytes C++<br>
> msvcr100d.dll!_nh_malloc_dbg(unsigned int nSize, int nhFlag, int<br>
> nBlockUse, const char * szFileName, int nLine) Line 302 + 0x1d bytes C++<br>
> msvcr100d.dll!_malloc_dbg(unsigned int nSize, int nBlockUse, const char *<br>
> szFileName, int nLine) Line 160 + 0x1b bytes C++<br>
> mfc100ud.dll!operator new(unsigned int nSize) Line 321 + 0x10 bytes C++<br>
> SA_Sgmt.exe!operator new[](unsigned int count) Line 6 + 0x9 bytes C++<br>
> SA_Sgmt.exe!itk::ImportImageContainer<unsigned<br>
> long,float>::AllocateElements(unsigned long size) Line 178 + 0x19 bytes C++<br>
> SA_Sgmt.exe!itk::ImportImageContainer<unsigned<br>
> long,float>::Reserve(unsigned long size) Line 86 + 0x13 bytes C++<br>
> SA_Sgmt.exe!itk::Image<float,2>::Allocate() Line 52 C++<br>
> SA_Sgmt.exe!itk::ImageSource<itk::Image<float,2> >::AllocateOutputs()<br>
> Line 216 + 0x26 bytes C++<br>
> SA_Sgmt.exe!itk::ReconstructionImageFilter<itk::Image<float,2>,itk::Image<float,2>,std::greater<float><br>
>>::GenerateData() Line 112 + 0x12 bytes C++<br>
> When I commented the filter->update(), I don't see memory leak reported.<br>
><br>
> I hope those information can give us more ideas.<br>
><br>
> Thanks a lot,<br>
> Tina<br>
><br>
><br>
> On Sun, Sep 18, 2011 at 6:39 AM, Richard Beare <<a href="mailto:richard.beare@gmail.com">richard.beare@gmail.com</a>><br>
> wrote:<br>
>><br>
>> I've run a couple of tests with the mac leak detector and didn't see<br>
>> anything.<br>
>><br>
>> 2011/9/17 Gaëtan Lehmann <<a href="mailto:gaetan.lehmann@jouy.inra.fr">gaetan.lehmann@jouy.inra.fr</a>>:<br>
>> ><br>
>> > Hi,<br>
>> ><br>
>> > The memory leak message is not more detailed than that?<br>
>> > I'm afraid we can't do much with that, unfortunately...<br>
>> ><br>
>> > Regards,<br>
>> ><br>
>> > Gaëtan<br>
>> ><br>
>> ><br>
>> > Le 14 sept. 11 ā 18:11, qi yang a écrit :<br>
>> ><br>
>> >> Hi,<br>
>> >><br>
>> >> I have a memory leaking problem bothered me for hours...<br>
>> >><br>
>> >> My VS2010 detected a big memory leak after "filter->Update()" of<br>
>> >> ReconstructionByDilationImageFilter.<br>
>> >> The related code is as following:<br>
>> >> typedef itk::ReconstructionByDilationImageFilter<ImageType, ImageType><br>
>> >> FilterType;<br>
>> >><br>
>> >> FilterType::Pointer filter = FilterType::New();<br>
>> >><br>
>> >> filter->SetMarkerImage(markerImage);<br>
>> >><br>
>> >> filter->SetMaskImage(maskImage);<br>
>> >><br>
>> >> filter->Update();<br>
>> >><br>
>> >> Do I need to release something after using the filter? What's the<br>
>> >> related<br>
>> >> function?<br>
>> >><br>
>> >> Thanks for any tips!!<br>
>> >><br>
>> >> Thanks,<br>
>> >> Tina<br>
>> >> _____________________________________<br>
>> >> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>> >><br>
>> >> Visit other Kitware open-source projects at<br>
>> >> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>> >><br>
>> >> Kitware offers ITK Training Courses, for more information visit:<br>
>> >> <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
>> >><br>
>> >> Please keep messages on-topic and check the ITK FAQ at:<br>
>> >> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
>> >><br>
>> >> Follow this link to subscribe/unsubscribe:<br>
>> >> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
>> ><br>
>> > --<br>
>> > Gaëtan Lehmann<br>
>> > Biologie du Développement et de la Reproduction<br>
>> > INRA de Jouy-en-Josas (France)<br>
>> > tel: <a href="tel:%2B33%201%2034%2065%2029%2066" value="+33134652966">+33 1 34 65 29 66</a> fax: 01 34 65 29 09<br>
>> > <a href="http://mima2.jouy.inra.fr" target="_blank">http://mima2.jouy.inra.fr</a> <a href="http://www.itk.org" target="_blank">http://www.itk.org</a><br>
>> > <a href="http://www.bepo.fr" target="_blank">http://www.bepo.fr</a><br>
>> ><br>
>> ><br>
>> > _____________________________________<br>
>> > Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>> ><br>
>> > Visit other Kitware open-source projects at<br>
>> > <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>> ><br>
>> > Kitware offers ITK Training Courses, for more information visit:<br>
>> > <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
>> ><br>
>> > Please keep messages on-topic and check the ITK FAQ at:<br>
>> > <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
>> ><br>
>> > Follow this link to subscribe/unsubscribe:<br>
>> > <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
>> ><br>
>> ><br>
><br>
><br>
</div></div></blockquote></div><br>