[ITK] GDCM reader memory usage

Pölönen Harri Harri.Polonen at vtt.fi
Mon Mar 31 04:31:47 EDT 2014


Hi all!

I'm reading some DICOM data with GDCMImageIO, but I end up having double amount of memory reserved than what the actual data would require.

Below you can find my simple test program and in the comments you can see where memory is reserved. I can understand that reader->Update() causes memory reservation but why another piece of memory is reserved within nameGenerator->SetInputDirectory()? Is this intended behaviour? My data size is about 178 MB (511x511x359 of unsigned short) so reserving more than 400 MB is way too much.

I found an ugly way to circumvent this by putting some lines within parenthesis, so that the nameGenerator variable gets cleared when it drops out of scope (commented parenthesis in the code).  But I guess this should be fixed in some better way?

Thanks!

Harri, Finland


#include "itkImageSeriesReader.h"
#include "itkGDCMImageIO.h"
#include "itkGDCMSeriesFileNames.h"

int main(int argc, char* argv[])
{
               typedef unsigned short       PixelType;
               const unsigned int         Dimension = 3;

               typedef itk::Image< PixelType, Dimension >      ImageType;

               typedef itk::ImageSeriesReader< ImageType >     ReaderType;
               ReaderType::Pointer reader = ReaderType::New();

               typedef itk::GDCMImageIO       ImageIOType;
               ImageIOType::Pointer dicomIO = ImageIOType::New();

               reader->SetImageIO(dicomIO);
               reader->SetUseStreaming(true);

               typedef itk::GDCMSeriesFileNames     NamesGeneratorType;

               //{
               NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
               nameGenerator->SetInputDirectory(argv[1]); // Memory usage jumps from 13 MB to 202 MB

               typedef std::vector<std::string>    FileNamesContainer;
               FileNamesContainer fileNames = nameGenerator->GetInputFileNames();
               reader->SetFileNames(fileNames);
               //}

               try
               {
                             reader->Update(); // Memory usage jumps from 202 MB to 413 MB
               }
               catch (itk::ExceptionObject &ex)
               {
                             std::cout << ex << std::endl;
                             return EXIT_FAILURE;
               }

               return EXIT_SUCCESS;
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140331/ee9075fb/attachment-0001.html>


More information about the Community mailing list