Hi,<br><br>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).
<br>The error that I get is the following:<br>---------------<br>itk::ExceptionObject &lt;01C5AC80&gt;<br>Location: &quot;unsigned char *_thiscall itk::ImportImageContainer&lt;unsigned long,unsigned char&gt;::AllocateElements&lt;unsigned long&gt; const&quot;
<br>File: c:\myinstalls\insighttoolkit-3.2.0\code\common\itkImportImageContainer.txx<br><br>Line: 188<br>Description: Failed to allocate memory for image.<br>---------------<br><br>The images don&#39;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 -<br>--------<br>const unsigned int InputDimension =3;<br>typedef unsigned char InputPixelType;<br>typedef itk::Image&lt; InputPixelType, InputDimension &gt; InputImageType;
<br>typedef itk::ImageFileReader&lt; InputImageType &gt; ReaderType;<br>typedef itk::GDCMImageIO ImageIOType;<br><br>unsigned long fni;<br>for(fni=0;fni&lt;250000;fni++)<br>{<br><br>&nbsp;&nbsp; &nbsp;ReaderType::Pointer reader2 = ReaderType::New();
<br><br>&nbsp;&nbsp; &nbsp;ImageIOType::Pointer gdcmImageIO2 = ImageIOType::New();<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;[set filename for reader2] <br>&nbsp;&nbsp; &nbsp;//fname = this-&gt;directory-&gt;absoluteFilePath(this-&gt;files[fni]);<br>&nbsp;&nbsp; &nbsp;//reader2-&gt;SetFileName(std::string(
fname.toAscii()));<br><br>&nbsp;&nbsp; &nbsp;reader2-&gt;SetImageIO(gdcmImageIO2);<br>&nbsp;&nbsp; &nbsp;try<br>&nbsp;&nbsp; &nbsp;{<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;reader2-&gt;Update(); <br>&nbsp;&nbsp; &nbsp;}<br>&nbsp;&nbsp; &nbsp;catch (itk::ExceptionObject &amp; e)<br>&nbsp;&nbsp; &nbsp;{<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;std::cerr &lt;&lt; &quot;exception in file reader &quot; &lt;&lt; std::endl;
<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;std::cerr &lt;&lt; e &lt;&lt; std::endl;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return EXIT_FAILURE;<br>&nbsp;&nbsp; &nbsp;}<br><br>&nbsp;&nbsp; &nbsp;[ code for processing information from header of each image here]<br><br>&nbsp;&nbsp; &nbsp;//reader2-&gt;Delete();//not implemented
<br>&nbsp;&nbsp; &nbsp;//gdcmImageIO2-&gt;Delete();//not implemented<br><br>}<br>----------<br>I cannot call a delete inside the &#39;for&#39; loop. It gives me an error saying that an error has occured and do you want to send information to Microsoft?
<br>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.<br>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?
<br>I will really appreciate if someone can help me with this.<br><br>Thanks,<br>Ashish