This is the kind of problem you run into when you put live object systems onto dead VMs: people start trying to fix the wrong things. Here's Charles Nutter, complaining about ObjectSpace (which is apparently how Ruby manages "all instances") - he wants to get rid of it for JRuby:
There are no plans currently for ObjectSpace to be removed from Ruby in a future version. But there's a problem...in addition to being pure overhead in JRuby (which you can turn off completely by using the -O flag), ObjectSpace limits evolving development of the Ruby garbage collector, breaks heap and memory transparency, and poses yet more problems for threading.
There are many issues here. First off, the JRuby thing. By having to add ObjectSpace governors for all objects in the system, JRuby pays a very large penalty. We're forced to do this because the JVM (and most other advanced garbage-collecting VMs) does not allow you to traverse in-memory objects nor retrieve the object that is associated with a given ID. In general this is because the JVM does all sorts of wonderful and magical things with objects and memory behind the scenes, and the ability to ask for all objects of a given type or pull an object based on some ID number at any time cripples many of these tricks.
The base problem is that the JVM sucks for hosting dynamic languages, and this is just one of the many ways it sucks. Before Charles tosses this feature overboard, he might want to have a look at my last post for an idea as to why such functionality is valuable. Here's a thought - add proper support for dynamic languages to the JVM.
Tossing the baby out with the bathwater isn't really an answer - at least, not a serious one. Down that road you get Java with Ruby syntax, which just doesn't sound that interesting.
Technorati Tags: live objects