[Insight-users] Failed to allocate memory for image

Ashish Singh mrasingh at gmail.com
Mon Aug 27 12:35:39 EDT 2007


Hi Luis,

Thanks for replying.I am using ITK- 3.2.0.

How do I modify this code without having to create reader and GDCMImageIO at
every iteration? Maybe that is what is creating problem here.
I am going to run the application with the' header processing part'
suppressed and will let you know exactly what happens. In the meantime, if
you can tell me the modifications for using single reader and GDCMImageIO
for all images, I could try that out too.

Thanks,
Ashish

On 8/27/07, Luis Ibanez <luis.ibanez at kitware.com> wrote:
>
>
> Hi Ashish,
>
> What version of ITK are you using ?
>
>    This looks like a memory leak...
>
> Note that you really don't have to create
> the reader an the GDCMImage IO at every
> iteration of the loop. That being said,
> your code is still a valid construction.
>
> Do you get the same error if you suppress
> the code that is "oprocessing information from
> header of each image" ?
>
> It may be that that section of code contains
> a memory leak...
>
>
>    Please let us know
>
>
>       Thanks
>
>
>           Luis
>
>
> --------------------
> Ashish Singh wrote:
> > Hi,
> >
> > I have written an application to read and process dicom header
> > information. My application runs fine for small number of images but
> > gives an error when it reaches about 70,000 images(the number varies
> > each time).
> > The error that I get is the following:
> > ---------------
> > itk::ExceptionObject <01C5AC80>
> > Location: "unsigned char *_thiscall itk::ImportImageContainer<unsigned
> > long,unsigned char>::AllocateElements<unsigned long> const"
> > File:
> > c:\myinstalls\insighttoolkit-
> 3.2.0\code\common\itkImportImageContainer.txx
> >
> > Line: 188
> > Description: Failed to allocate memory for image.
> > ---------------
> >
> > The images don't belong to a single series.The application is running on
> > windows XP Pro x64 platform. The relevant portion of the code looks like
> > this -
> > --------
> > const unsigned int InputDimension =3;
> > typedef unsigned char InputPixelType;
> > typedef itk::Image< InputPixelType, InputDimension > InputImageType;
> > typedef itk::ImageFileReader< InputImageType > ReaderType;
> > typedef itk::GDCMImageIO ImageIOType;
> >
> > unsigned long fni;
> > for(fni=0;fni<250000;fni++)
> > {
> >
> >     ReaderType::Pointer reader2 = ReaderType::New();
> >
> >     ImageIOType::Pointer gdcmImageIO2 = ImageIOType::New();
> >
> >     [set filename for reader2]
> >     //fname = this->directory->absoluteFilePath(this->files[fni]);
> >     //reader2->SetFileName(std::string( fname.toAscii()));
> >
> >     reader2->SetImageIO(gdcmImageIO2);
> >     try
> >     {
> >         reader2->Update();
> >     }
> >     catch (itk::ExceptionObject & e)
> >     {
> >         std::cerr << "exception in file reader " << std::endl;
> >         std::cerr << e << std::endl;
> >         return EXIT_FAILURE;
> >     }
> >
> >     [ code for processing information from header of each image here]
> >
> >     //reader2->Delete();//not implemented
> >     //gdcmImageIO2->Delete();//not implemented
> >
> > }
> > ----------
> > I cannot call a delete inside the 'for' loop. It gives me an error
> > saying that an error has occured and do you want to send information to
> > Microsoft?
> > I also did some reading in ITK software guide, where it says that a
> > smart pointer takes care of delete by itself. I also tried Register(),
> > UnRegister(), ReleaseDataFlagOn().None of these work.
> > Can anyone please tell me what is going wrong here and how to fix it?
> > How can I release the memory for the reader? Is there a simpler way to
> > do this?
> > I will really appreciate if someone can help me with this.
> >
> > Thanks,
> > Ashish
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070827/ae2a8d9b/attachment.htm


More information about the Insight-users mailing list