[Insight-users] how to free up the memory]

Gavin Baker gavinb+xtk at cs.mu.OZ.AU
Thu Jan 27 23:38:11 EST 2005


Hello Quan,

On Wed, Jan 26, 2005 at 03:00:13PM -0600, Quan Chen wrote:
> Hi, I am doing some CT segmentation and run into in-sufficient memory
> problem.  I did a lot of pre-processing and use a lot of filters.  Those
> filters connected to form a pipeline.  However, since my CT image is pretty
> big, it quickly depleted my 2G memory and prevent me from proceed with my
> pipeline.  I am wondering can I delete the memory allocated by the filter I
> used in the previous steps?  I already invoked Update() function in the
> middle of the pipeline and got the intermediate result, so it shouldn't
> affect the running of the rest of the pipeline.

You can use the SetReleaseDataFlag on the readers, or upstream filters
you know you won't need again.  This should free up a fair amount of
memory; obviously it all depends on the pipeline.

You can call:

  image->GetBufferedRegion().GetNumberOfPixels()

to see how much memory is being retained at stages of the pipeine.

> Another problem that I encountered before, which might also relate to this
> memory allocate/free problem.   BTW, I normally modify the sample
> applications with GUI, such as GeodesicActiveContour.  I find that everytime
> when I load a new image (which have dimension different from the previously
> loaded image), the load itself is ok but when I update the subsequent filter
> to perform processing, the program will exit abnormally.  I am wondering if
> it is because some filters will allocate the necessary memory when it first
> execute but don't check if the input image dimension has changed.

After the first Update() call, a filter will cache the requested
region.  So when you load a new file, you need to force the filters to
update themselves with the new region info (which may be different) by
calling UpdateLargestPossibleRegion().

Regards,

  :: Gavin

-- 
Gavin Baker                                      Complex Systems Group
http://www.cs.mu.oz.au/~gavinb             The University of Melbourne

----- End forwarded message -----

  :: Gavin

-- 
Gavin Baker                                      Complex Systems Group
http://www.cs.mu.oz.au/~gavinb             The University of Melbourne


More information about the Insight-users mailing list