I believe clean may be ok, unless there's a ton of WeakReferences getting collected. clean repeatedly polls the ReferenceQueue for any collected references, removing them from ObjectSpace. According to JavaDocs and the 1.5 ReferenceQueue implementation, each poll should just pull the 'head' item off the queue or return null. In cases where there's nothing in the queue, calling clean starts the loop, polls the queue (which synchronizes) and then immediately completes.

However, I think a better implementation would be to have ObjectSpace implement an internal ReferenceQueue to immediately remove object references upon collection. That may be the best way to handle all our various uses of WeakReferences, and would then completely eliminate the need for a "clean" method at all.

My guess is that the cost is more in maintaining the HashSet than anything else. Every new object needs to calculate a new Hash, and we've seen in the past that heavy map maintenance--especially in code called a bazillion times--can be a sizeable performance hit.

On 6/2/06, Ola Bini <[EMAIL PROTECTED]> wrote:
Hi,

Regardig the ObjectSpace-implementation, I would recommend you to move the
cleanup call to ObjectSpace#iterator() ... I think that's where most of the
performance go through the roof.
And it's not like those WeakReferences are a problem...

/O

--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ jruby.sourceforge.net
Application Architect @ www.ventera.com
_______________________________________________
Jruby-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jruby-devel

Reply via email to