[Insight-users] Failed to allocate memory for image

Luis Ibanez luis.ibanez at kitware.com
Thu Sep 14 14:33:26 EDT 2006


Hi Laurent,

If you are using Windows in a 32bits machine,
you can only use 2Gb per process.


    Regards,


       Luis


----------------------
Laurent PAUL wrote:
> Hi Luis,
> 
> I'm in holiday for the moment, I'll try that as soon as I will be back.
> 
> Now, I understand why registration crashes despite my huge memory and swap!
> Is there any Windows limitation in memory attributed to process/program?
> 
> Thanks,
> 
> Laurent.
> 
> 
> 
>>Hi Laurent,
>>
>>
>>Could you please try the following ?
>>
>>add the call:
>>
>>
>>       metric->SetComputeGradient( false );
>>
>>before invoking Initialize()
>>
>>It is likely that the filter that computes
>>the image gradients is demanding too much
>>memory.
>>
>>This filter: the GradientRecursiveGaussianImageFilter
>>uses an internal minipipeline that in 3D has 2
>>smoothing filters and one derivative filter. The total
>>process of computing the gradient of your image can
>>easily allocate six times the original size of the image,
>>but with float pixels. So, if your images were using
>>1byte pixel types, then the gradient filter requires
>>24 times the amount of memory of the input image.
>>This would be clearly outside of the capability of your
>>RAM (although... your swap should have helped here...).
>>
>>This filter is greedy in memory, in order to be fast
>>in execution. For large images, this may not be a wise
>>choice. You may have to replace the filter with the
>>GradientImageFilter.
>>
>>
>>
>>Please let us know what you find.
>>
>>
>>    Thanks
>>
>>
>>       Luis
>>
>>
>>-------------------
>>Laurent PAUL wrote:
>>
>>>Hi Ming, hi Luis,
>>>
>>>Ming seems to have the same problem than mine.
>>>
>>>I register two volumes ~110Mo each, but program crashes, with the same
>>>exception object.
>>>I'm sure this registration had ever worked one time with the same
>>>computer
>>>(even with larger volumes)!
>>>
>>>I try adding 'metric->Initialize()' inside a try/catch block.
>>>First, I added:
>>>
>>>  metric->SetFixedImage ( FixedImage );
>>>  metric->SetFixedImageRegion(FixedImage->GetLargestPossibleRegion());
>>>  metric->SetMovingImage( MovingImage );
>>>  metric->SetTransform(transform);
>>>  metric->SetInterpolator(  interpolator  );
>>>
>>>because itkMeanSquaresImageToImageMetric was complaining.
>>>
>>>Then I caught an exception, the same than I had before:
>>>------------------------------------------------------
>>>itk::ExceptionObject (0117F854)
>>>Location: "unknown"
>>>File:
>>>C:\lib\ITK\InsightToolkit-2.8.1\Code\Common\itkImportImageContainer.txx
>>>Line: 188
>>>Description: Failed to allocate memory for image.
>>>-------------------------------------------------------
>>>
>>>Like Ming, I got lot more memory than needed (2Go).
>>>I monitored its use with task manager:
>>>
>>>up to 1100Mo total memory usage ( 800 Mo for registration program) after
>>>reading both fixed and moving volumes.
>>>It goes down to 770 Mo total usage (470 Mo for registration) after
>>>destruction of intermediate filters (casters).
>>>
>>>At this point, program crashes with error message doing
>>>metric->Initialize().
>>>
>>>I compared MeanSquaresImageToImageMetric and itkImportImageContainer.txx
>>>in both distribution, ITK 2.6 and ITK 2.8.1, they are identical except a
>>>#include "itkImportImageContainer.h".
>>>
>>>Is there any changes in code which produce this behavior?
>>>Is there any windows limitation about memory usage for one application?
>>>
>>>Let me know if you want more details.
>>>
>>>Thanks,
>>>
>>>Laurent.
>>>
>>>
>>>
>>>
>>>
>>>
>>>Hi Ming,
>>>
>>>Thanks for providing the answers to our questions.
>>>
>>> From the additional information that you posted, it
>>>seems that the main suspect may be the computation
>>>of the gradient image that is performed during the
>>>initialization of the ImageMetric.
>>>
>>>
>>>Please add a call:
>>>
>>>      metric->Initialize()
>>>
>>>just before you call
>>>
>>>       registrationMethod->StartRegistration()
>>>
>>>and put a try/catch() block aroung the metric->Initialize()
>>>call, along with a very unique message in the catch block.
>>>
>>>Then rerun your registration.
>>>
>>>In this way we should be able to identify if the problem
>>>happens during the initialization of Metric.
>>>
>>>
>>>Please let us know what you find.
>>>
>>>
>>>
>>>    Thanks
>>>
>>>
>>>
>>>      Luis
>>>
>>>
>>>-------------------
>>>Ming Chao wrote:
>>>
>>>
>>>>Hi Luis,
>>>>
>>>>Sorry for my late response. Please see the following for your questions.
>>>>
>>>>
>>>>What tool did you used for monitoring the memory usage ?
>>>>
>>>>The tool I used is just the Windows Task Manager.
>>>>
>>>>What was the memory usage for the entire machine ?
>>>>(you only reported the usage for the registration application).
>>>>
>>>>I don't remember the exact number, but I do know that the registration
>>>
>>>application had the largest consumption of memory.  I am sure the total
>>>memory usage did not exceed the allowed memory.
>>>
>>>
>>>>Do you have other applications running at the same time that
>>>>your are running the registration application ?
>>>>
>>>>No.
>>>>
>>>>In Windows 32 bits, a process can only access 2Gb of contiguous
>>>>RAM.
>>>>
>>>>What Image Metric are you using ?
>>>>(e.g. is it one of the metrics that computes the image gradient?)
>>>>
>>>>Normalized Cross Correlation.
>>>>
>>>>What other ITK and/or VTK filter do you have in that pipeline.
>>>>
>>>>I did not have any other filters.
>>>>
>>>>At what point in the execution of your program do you get this
>>>>message ?
>>>>
>>>>Before the first iteration during the registration which is actually a
>>>
>>>rigid one.
>>>
>>>
>>>>Have the registration started ?
>>>>
>>>>Yes.
>>>>
>>>>Do you got some optimization iterations ?
>>>>
>>>>No.
>>>>
>>>>It is very likely that you are actually using most of those
>>>>2Gb of data, and may have to release memory as your appllication
>>>
>>>progresses with its pipeline.
>>>
>>>
>>>>I am not sure what you meant here. Why do you say that I used most of
>>>
>>>the 2GB data? How can I release memory?
>>>
>>>
>>>>I want to repeat that my registration is actually very simple one, ie,
>>>
>>>rigid registration. I don't have any intermediate filters. Hope my
>>>answers to your questions help to debug the problem.
>>>
>>>
>>>>Thanks,
>>>>Ming
>>>>
>>>>
>>>>
>>>>--------------------
>>>>Ming Chao wrote:
>>>>
>>>>>Hi,
>>>>>
>>>>>I know this question has been asked many times, but it's still not
>>>
>>>clear
>>>
>>>
>>>>>to me how to solve it. I try to register two images which are ~70mb
>>>
>>>each
>>>
>>>
>>>>>(512X512X136). I got the the following error:
>>>>>
>>>>>===================================
>>>>>ExceptionObject caught !
>>>>>
>>>>>itk::ExceptionObject (0129FB70)
>>>>>Location: "unknown"
>>>>>File: C:
>>>>
>>>>\ITK\InsightToolkit-2.8.1\Code\Common\itkImportImageContainer.txx
>>>>
>>>>>Line: 188
>>>>>Description: Failed to allocate memory for image.
>>>>>
>>>>>===================================
>>>>>
>>>>>I am using ITK 2.8.1, VTK 5.01, VC++ 6.0. The operating system is
>>>
>>>Windows XP professional edition (32 bits) with Xeon CPU 3.6GHz and
>>>3.0
>>>
>>>
>>>>>GB memory. I monitored the memory usage and found that only 280 MB
>>>
>>>used
>>>
>>>
>>>>>for the registration process which is nothing unreasonable. What is
>>>
>>>wrong here? How to solve the problem. I know if I filtered the image
>>>by
>>>
>>>
>>>>>2X2, then it would be fine, but I would still like to keep the image
>>>
>>>as
>>>
>>>
>>>>>it is.
>>>>>
>>>>>Thanks for any hints,
>>>>>Ming
>>>>>
>>>>>
>>>>>
>>>>>------------------------------------------------------------------------
>>>>>
>>>>>_______________________________________________
>>>>>Insight-users mailing list
>>>>>Insight-users at itk.org <mailto:Insight-users at itk.org>
>>>>>http://www.itk.org/mailman/listinfo/insight-users
>>>>
>>>><http://www.itk.org/mailman/listinfo/insight-users>
>>>>
>>>>
>>>
>>>
>>>
>>>_______________________________________________
>>>Insight-users mailing list
>>>Insight-users at itk.org
>>>http://www.itk.org/mailman/listinfo/insight-users
>>>
>>
>>
>>
> 
> 
> 
> 




More information about the Insight-users mailing list