Okay. What if, in an extension, I have an integer on the
stack that just happens to contain a value that interpreted
as a pointer points into a valid point in the heap. Will
that prevent the “pointed to” object from being gc’ed?
Yes. The Ruby collector is a conservative collector, meaning that it will
only find garbage, but might not find /all/ the garbage.
···
–
– Jim Weirich / Compuware
– Fidelity/FWP Capture Services
– Phone: 859-386-8855
Yes. The Ruby collector is a conservative collector, meaning that it will
only find garbage, but might not find /all/ the garbage.
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?
Thomas
Hi,
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.
However, you have to pay attention in this situation.
VALUE str = rb_str_new(0, 256); /* make a buffer */
char *ptr = RSTRING(str)->ptr;
If str isn’t used later, compiler may remove it. And then ptr
may be freed when you call ruby APIs and GC runs.
StringValue() and StringValuePtr() are provided to avoid this.
···
At Wed, 8 Oct 2003 23:09:08 +0900, Thomas Sondergaard wrote:
–
Nobu Nakada
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.
Sean O'Dell
···
nobu.nokada@softhome.net wrote:
Hi,
At Wed, 8 Oct 2003 23:09:08 +0900, > Thomas Sondergaard 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.