oops -- since actual body of this very email wasn't already duplicated,
here it is:

Dear ITK maintainer, see attached patch which fixes memory leak for
subsequent loads of NIFTI files.  I've tested the patch with ants --
this huge leak seems to be gone... there is something left (see below)
but that might still be ANTs issue (thus feel free to ignore, for now
;)):

==12852== 1,648 (784 direct, 864 indirect) bytes in 2 blocks are definitely 
lost in loss record 7 of 7
==12852==    at 0x4C249C7: operator new(unsigned long) (vg_replace_malloc.c:220)
==12852==    by 0x483391: itk::MatrixOffsetTransformBase<double, 3u, 3u>::New() 
(itkMatrixOffsetTransformBase.h:95)
==12852==    by 0x4BC962: 
itk::CreateObjectFunction<itk::MatrixOffsetTransformBase<double, 3u, 3u> 
>::CreateObject() (itkCreateObjectFunction.h:69)
==12852==    by 0x4EFA132: itk::ObjectFactoryBase::CreateObject(char const*) 
(in /usr/lib/libITKCommon.so.3.18.0)
==12852==    by 0x4EFBA74: itk::ObjectFactoryBase::CreateInstance(char const*) 
(in /usr/lib/libITKCommon.so.3.18.0)
==12852==    by 0x5306FDB: itk::TransformFileReader::Update() (in 
/usr/lib/libITKIO.so.3.18.0)
==12852==    by 0x47A97E: void WarpImageMultiTransformFourD<4>(char*, char*, 
std::vector<TRAN_OPT, std::allocator<TRAN_OPT> >&, MISC_OPT&) 
(WarpTimeSeriesImageMultiTransform.cxx:569)
==12852==    by 0x473235: main (WarpTimeSeriesImageMultiTransform.cxx:1004)


-- 
                                  .-.
=------------------------------   /v\  ----------------------------=
Keep in touch                    // \\     (yoh@|www.)onerussian.com
Yaroslav Halchenko              /(   )\               ICQ#: 60653192
                   Linux User    ^^-^^    [175555]


--- insighttoolkit-3.18.0.orig/Code/IO/itkNiftiImageIO.cxx
+++ insighttoolkit-3.18.0/Code/IO/itkNiftiImageIO.cxx
@@ -457,6 +457,10 @@
     _size[4] = numComponents;
     }
 
+  // Free memory if any was occupied already
+  if (this->m_NiftiImage != NULL)
+      nifti_image_free(this->m_NiftiImage);
+
   //
   // allocate nifti image...
   this->m_NiftiImage = nifti_image_read(this->GetFileName(),false);

Attachment: signature.asc
Description: Digital signature

Reply via email to