2008/10/28 Paul Brannan <pbrannan / atdesk.com>:
> On Wed, Oct 29, 2008 at 01:04:52AM +0900, Roger Pack wrote:
>> A way to avoid this [as Boehm does (?)] would be to throw up a write
>> barrier during collection and search it in the parent thread for new
>> references--I am somewhat scared of doing so since it sounds hard :)
>
> Requiring all ObjectSpace methods to grab a mutex and wait for the
> collector to complete should probably be sufficient.

What about scenarios like this?

1. x = WeakRef.new(Object.new)
2. concurrent GC starts
3. y = x.__getobj__
4. concurrent GC removes the object referenced by x
5. concurrent GC finishes
6. y.boom()

Having to synchronize every WeakRef#__getobj__ can potentially be
disastrous for performance.

What about classifying objects by their reachability (strong, weak,
none)?  Probably a bad idea: this would have a dramatic overhead for
weakly reachable objects which are actually used (they would oscillate
between "weak" and "strong").

> #each_object becomes tricky, because you still want the collector to be
> invokable when you are iterating over all objects.  The easiest solution
> is to disable #each_object when your patch is enabled.

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

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end