[vtkusers] vtkDICOMImageReader possible leak.

Mathieu Malaterre mathieu.malaterre at kitware.com
Wed Nov 16 10:06:01 EST 2005


Wilbur,

	Thanks for the bug report this is fixed in VTK CVS.

$ cvs ci -m"BUG: Fix leak, thanks to Wilbur C. K. Wong" 
vtkDICOMImageReader.cxx 
 
/cvsroot/ParaView/ParaView/VTK/IO/vtkDICOMImageReader.cxx,v  <-- 
vtkDICOMImageReader.cxx
new revision: 1.33; previous revision: 1.32

Best
Mathieu

Wilbur C.K. Wong wrote:
> Hi Mathieu,
> 
> In function,
> void vtkDICOMImageReader::ExecuteData(vtkDataObject *output)
> 
> Towards its end, you can find the following block of code:
> 
>       this->UpdateProgress(float(count)/float(numFiles));
>       int len = static_cast<int> (strlen((char*) (*fiter).c_str()));
>       char* filename = new char[len+1];
>       strcpy(filename, (char*) (*fiter).c_str());
>       this->SetProgressText(filename);
> 
> The memory leak is due to the creation of the character array,
> filename.  All you need to do is to delete it after the
> SetProgressText is called.
> 
>       /* A bug that leads to memory leak. */
>       delete [] filename;
> 
> Hope this can help.
> 
> Best,
> Wilbur C. K. Wong 黃進傑(黄进杰)
> Ph.D. Student
> 
> Lo Kwee-Seong Medical Image Analysis Laboratory
> Computer Science - Hong Kong University of Science & Technology
> cswilbur "AT" ust "DOT" hk | wilburckwong "AT" gmail "DOT" com
> http://www.cs.ust.hk/~cswilbur | http://www.wilburwong.ws
> 
> Medical Image Processing and Analysis | Computer-aided Endovascular
> Treatment Project
> 
> 
>>mathieu coursolle mcoursolle at gmail.com
>>Sat Jun 11 16:30:21 EDT 2005
>>
>>    * Previous message: [vtkusers] fortran binary
>>    * Next message: [vtkusers] Can't use vtkSliceCubes
>>    * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>>
>>Hi to all,
>>I was wondering if any of you have ever had a memory leak problem
>>using vtkDICOMImageReader (VTK 4.4).
>>The following codes produces some leaks, but only when I open a volume.
>>
>>            //Create the reader.
>>            vtkDICOMImageReader* reader_ptr = vtkDICOMImageReader::New();
>>            vtkSmartPointer<vtkDICOMImageReader> reader(reader_ptr);
>>            reader_ptr->Delete();
>>
>>            //Load the file.
>>            reader->SetDirectoryName(D:\\DICOM);
>>            reader->Update();
>>
>>Otherwise it works fine.
>>
>>Thanks.
>>
>>MAthieu
>>
>>
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>This is the private VTK discussion list. 
>>Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>>Follow this link to subscribe/unsubscribe:
>>http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list