[Insight-users] Failed to allocate memory in filtering an image by Canny

Luis Ibanez luis.ibanez at kitware.com
Wed Aug 9 19:56:11 EDT 2006


Hi Yan,

1) How much memory do you have in your system ?

2) How many other ITK filters do you have in your pipeline ?

3) How many other applications did you have open with
    you run this program ?

4) Are you monitoring your memory usage using the Windows Task Manager ?
    if so, do you have any reason for suspecting a memory leak ?


Assuming that your machine has a reasonable amount of memory
(These days : 512Mb to 2Gb), and that you don't have other
applications taking a significant amount of that memory, and that
your ITK application is the only one running at this point, then
your best option is to add "ReleaseDataFlagOn()" calls to all
your ITK filters before you run your pipeline. This will make the
filters release memory as the execution of the pipeline progresses.

In this way only the filter being executed, and the filter providing
input to this one, will be taking memory for their output images.


With this in mind, you may want to take a fresh look at the memory
resources.


   Please let us know what you find,



      Thanks



        Luis



---------------
Yan Yang wrote:
> Dear All,
>  
> I got a memory allocation problem, please see the copied error message 
> below. I would be very grateful if anyone could help me solve this problem.
>  
> My data:
> Dimension: 512x512x277
> Pixel Type: signed short
>  
> Operation: Generate the edge map of the input image using 
> CannyEdgeDetectionImageFilter
>  
> Code snippet:
> CastToReal->SetInput( inputImage ); 
> cannyFilter->SetInput( CastToReal->GetOutput() );
> cannyFilter->SetVariance( 0.5 );
> cannyFilter->SetLowerThreshold( 255 );
> cannyFilter->SetUpperThreshold( 90 );
> cannyFilter->Update();
>  
> rescaleToChar->SetOutputMinimum( NumericTraits< CharPixelType >::min() );
> rescaleToChar->SetOutputMaximum( NumericTraits< CharPixelType >::max() );
> rescaleToChar->SetInput( cannyFilter->GetOutput() );
> rescaleToChar->Update();
>  
> An error occured at runing the line "rescaleToChar->Update();", the 
> error message is as the following.
>  
> ----------------------------------------------------------------------------------------------------------------------------------------------
> itk::ExceptionObject (0138F9D8)
> Location: "ImportImageContainer::AllocateElements"
> File: 
> C:\Librabries\InsightToolkit-2.4.1\InsightToolkit-2.4.1\Code\Common\itkImp
> ortImageContainer.txx
> Line: 186
> Description: Failed to allocate memory for image.
>  
> 
> Caught an ITK exception at executing registration app.
>  
> itk::ExceptionObject (0138F9D8)
> Location: "ImportImageContainer::AllocateElements"
> File: 
> C:\Librabries\InsightToolkit-2.4.1\InsightToolkit-2.4.1\Code\Common\itkImp
> ortImageContainer.txx
> Line: 186
> Description: Failed to allocate memory for image.
> -------------------------------------------------------------------------------------------------------------------------------------------------
>  
> Many thanks in advance.
>  
> Yan
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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