[Insight-users] Failed to allocate memory for image

Ashish Singh mrasingh at gmail.com
Mon Aug 27 11:00:00 EDT 2007


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070827/9c9396d2/attachment.htm


More information about the Insight-users mailing list