Hi.

The big problem with ObjectSpace seems to be that it punishes even those
who aren't using it in the current implementation. If we changed the
implementation to something like this:
    private List references = new ArrayList();
    private Set realReferences = null;
    private ReferenceQueue deadReferences = new ReferenceQueue();

    public void add(IRubyObject object) {
        references.add(new WeakReference(object, deadReferences));
    }

    public Iterator iterator(RubyModule rubyClass) {
        cleanup();
        realReferences = new HashSet(references);
        return new ObjectSpaceIterator(rubyClass);
    }


The point of this exercise being that it _should_ be dead fast to create
a new WeakReference, and add at the end of an arraylist. If something
actually wants to iterate over ObjectSpace, this will be slower, since
we do both cleanup and hash all the objects we have references too. But
this hit will only be for those using ObjectSpace.

What d'you think?

/O


_______________________________________________
Jruby-devel mailing list
Jruby-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jruby-devel

Reply via email to