[ITK-users] R-SimpleITK memory management

Mathew Guilfoyle mrguilfoyle at gmail.com
Wed Jul 6 09:55:45 EDT 2016


I'm processing a large number of CT scans using R wrapped SimpleITK
(some filtering and then registration before a segmentation).   I'm
running R within RStudio on OS X 10.11

I'm running into memory problems with long processing runs.  Though in
the R loops I reassign new images to the same R variable the
underlying C++ objects do not seem to get deleted but accumulate on
each loop - I can see steadily rising memory usage in Activity Monitor
until R/RStudio crashes.  I have tried explicitly deleting the
temporary images during each loop and calling the R garbage collector
(gc()), but it doesn't seem to have an effect.  If I restart the R
session then the memory is cleared.

My understanding was that the C++ objects would get garbage collected
once all pointers are removed but this doesn't seem to happen.  Is
there a method to explicitly delete the C++ image objects so I can
manage the memory usage myself?

Cheers


More information about the Insight-users mailing list