Ruby callcc captures the current continuation, which you can later call to restore the control, but not the data. I would like to capture the current continuation along with the current memory image.
It seems to me that grabbing a heap does not have to be very difficult; I can rely on ObjectSpace::each_object and ObjectSpace::dump_all , or Marshal.dump , or just Object.clone . However, I do not see a direct way to restore the heap. Ideally, I would like to cross the map object_id -> object , restoring the old image of the object for each object_id (and re-adding object_id if the corresponding object was GC'd). No wonder Api doesn't have a Ruby level that allows me to do this. I am wondering if there are any low level hooks for Ruby GC that I can use.
Any help is appreciated, including suggestions for alternative approaches.
garbage-collection ruby callcc
Gowtham kaki
source share