How thorough is GC.start in MRI Ruby 2.0?

184 Views Asked by At

In MRI Ruby 2.0, how thorough is GC.start?

Does it try to garbage collect all objects that no longer have a reference to them? Or does it only GC objects if it thinks it's necessary?

I'm trying to track the number of objects of a certain class I have, and it seems to keep on increasing even though I think some of the objects no longer have a reference to them. Using GC.start doesn't fix this. I don't use any C extensions, so that can't be complicating things.

Edit: The problem I was having was the same as in Ruby Symbol#to_proc leaks references in 1.9.2-p180? - objects still existed when I thought they ought to have been garbage collected, and like in that case, the problem was to do with using implicit Symbol -> Proc. However, it would be nice to know if GC.start is expected to garbage collect all objects, or merely collect whatever MRI thinks is necessary to garbage collect.

0

There are 0 best solutions below