Moi,

thanks for all previous answers, it's now working quite fine.

But there is a problem I could solve with what is called a weak 
reference in Java.

I store Object references on the C side without the gc knowing about 
them. This is how it needs to be, because my cache shouldn't keep them 
from being collected. (unless there is another way here ?)
But how can I ensure later that dereferencing my reference won't result 
in a core dumped ? Eg, when the memory has been reallocated and my 
pointer points somewhere into the middle of an object.
Is there a way to save a unique bitpattern, so when I go back I'd know 
it's an object. BTW: It's enough for me to know that a pointer is an 
object, I can find out if it's the right object by myself.
Can I get a call from ruby's gc when an object is collected ?
I found gc::is_pointer_to_heap , does that detemine if it's an object, 
or just if it sort of could be and given ruby's own usage pattern, 
surely is ?

Thanks
    Torsten