Matthew Metnetsky wrote:
> At this point I would like to force "obj" to be marked, and freed. But I am
> not sure what to do as rb_gc() does mark it, but it never gets freed.

It's actually the other way around: marked objects are _not_ freed. They 
are marked because they are reachable from some other live object.

So, if you have observed that rb_gc() is marking this object, then there 
is a reference somewhere. The tricky thing is that this reference could 
be bogus, such as a pointer left on the stack after some previous 
operation on the object. Ruby's GC is conservative (false positive is 
better than false negative!), so it has to assume that anything on the 
stack that looks like a pointer into the ruby heap is one.

Question: what kind of variable is your obj:

	VALUE obj = rb_class_new_instance(...)

If it is a stack variable, try setting obj = Qnil after unregistering it 
(in fact, IIUC register/unregister is not even necessary in this case, 
because of the way rb_gc() treats the stack).

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407