I\'m debugging a memory leak in a rake task. I want to see a call stack of:
There is a ruby-mass gem, which provides a nice api over ObjectSpace.
One of the ways to approach the problem is to check references after you've done with your object.
object = ...
# more logic
puts Mass.references(object)
If there is at least one reference, the object is not garbage collected and you need to figure out how to drop that reference. For example:
object.instance_variable_set("@example", nil)
# or
ObjectSpace.each_object(Your::Object::Class::Name).each do |obj|
obj.instance_variable_set("@example", nil)
end