From: nobu.nokada@... Date: 2003-10-09T07:15:50+09:00 Subject: Re: GC and the stack Hi, At Thu, 9 Oct 2003 02:27:08 +0900, Sean O'Dell wrote: > >>I have heard statements indicating that you need to declare all local VALUEs > >>volatile, in order to ensure that they are put on the stack by the compiler > >>and not in a register. Can I get an authoritative answer to this question? > >>The ruby source code is full of "volatile", but it is not mentioned once > >>either on the rubygarden.org WIKI or the README.EXT. Why should this be > >>necessary? Couldn't the garbage collector check the registers too? > > > > Unnecessary, in general. GC checks the registers of course. > > Actually, he does need to mark them as volatile. My objects were > getting reaped unexpectedly on me because of this. The Ruby GC might > check the registers, but it wasn't finding my objects there, and it was > a fantastic waste of many hours scratching my head. Indeed, you'll need StringValue() or something similar in such case. This might prevent it. *(volatile VALUE *)&reaped_object; -- Nobu Nakada