From: Joel VanderWerf Date: 2003-10-10T00:49:41+09:00 Subject: Re: Standard Queue Implementation and Thread Safety nobu.nokada@softhome.net wrote: > Hi, > > At Thu, 9 Oct 2003 14:03:13 +0900, > Joel VanderWerf wrote: ... >>I understand that Array#push could provoke a GC, but why would GC cause >>a context-switch? > > > Though, finalizers could interrupt. Since they run in same > thread and critical section so context won't switch, but they > may try to modify the object. > > $ ulimit -v 10240 > $ ruby > array = Array.new(100, nil) > while array.size > 10 > ObjectSpace.define_finalizer(Array.new(100000, nil)) {array.clear} > p array.push(nil).size > end Thanks, Nobu. I feel safer now, since I always regard finalizers with suspicion, anyway.