[vtkusers] vtkDICOMImageReader possible leak.

Wilbur C.K. Wong wilburckwong at gmail.com
Wed Nov 16 06:28:22 EST 2005


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 üSßM‚Ü£¨»Æ½ø½Ü£©
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
>


More information about the vtkusers mailing list