From: "ara.t.howard" Date: 2007-10-28T15:45:00+09:00 Subject: Re: How fast does your Ruby run? On Oct 28, 2007, at 12:17 AM, Charles Oliver Nutter wrote: > Not really; we've made it as lightweight as possible. The problem > is that there's no capability in the JVM to say "let me walk all > objects", largely because of how that would impact GC operation and > security (should objects created in other classloaders be walkable? > internal JVM objects? should you be able to reach objects you'd > *never* be able to construct or reference yourself? so many > questions). better you than me ;-) > > So the only way to ever be able to reach objects in the future is > to have a reference to them somewhere. So we create a very > lightweight linked list of references to all objects created. > However it gets more complicated: ObjectSpace references shouldn't > keep objects from getting collected. So every reference is a Java > weak reference, and we periodically clean the list of dead references. > > Tracking every object created + weak references + periodic cleanup > = slow. > > So ObjectSpace either needs to be there when the object is created, > or you must accept that you can't ever walk it. > hmmm. ok i'm brainstorming here which you can ignore if you like as i know less that nothing about jvms or implementing ruby but here goes: what if you could invert the problem? what i objects knew about the global ObjectSpaceThang and could be forced to register themselves on demand somehow? without a reference i've no idea how, just throwing that out there. or, another stupid idea, what if the objects themselves were the tree/graph of weak references parent -> children. crawling it would be, um, fun - but you could prune dead objects *only* when walking the graph. this should be possible in ruby since you always have the notion of a parent object - which is Object - so all objects should be either reachable or leaks. now back to drinking my regularly scheduled beer... cheers. a @ http://codeforpeople.com/ -- it is not enough to be compassionate. you must act. h.h. the 14th dalai lama