Robert Klemme wrote:
> ObjectSpace does create some issues for JRuby IIRC, so maybe we should
> consider whether we can get rid of it without too many disadvantages.

There's at least one important use case for ObjectSpace: closing all 
open IO objects. This is very important for daemonizing a process.

For example, Phusion Passenger's spawn manager calls fork(), after which 
it closes all file descriptors with C code. This turns out not to be 
enough: the resulting process may raise Errno::EBADFD at very strange 
and unexpected times. This is caused by the fact that there are still 
Ruby IO objects that think that the file descriptors are open, and thus 
any operations on those file descriptors will result in errors. This was 
fixed by performing:

   ObjectSpace.each_object(o) do
     if o.is_a?(IO)
       o.close rescue nil
     end
   end

The 'daemons' library also does something similar.

However, walking ObjectSpace is quite inefficient. I wouldn't mind 
getting rid of ObjectSpace if an alternative for closing all IO objects 
is provided.