[ITK] GDCM reader memory usage

Matt McCormick matt.mccormick at kitware.com
Mon Mar 31 11:57:47 EDT 2014


Hi Harri,

There is currently not another approach that I am aware of.

Matt

On Mon, Mar 31, 2014 at 4:31 AM, Pölönen Harri <Harri.Polonen at vtt.fi> wrote:
> 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;
>
> }
>
>
>
>
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/cgi-bin/mailman/listinfo/community
>



More information about the Community mailing list