Skip to content

Instantly share code, notes, and snippets.

@kellyredding
Created June 7, 2012 21:00
Show Gist options
  • Save kellyredding/2891503 to your computer and use it in GitHub Desktop.
Save kellyredding/2891503 to your computer and use it in GitHub Desktop.
ruby `ObjectSpace` usage from debugging a memory leak in inbox-sync
# used to make sure old mail items were getting garbage collected
# in the runner loop...
puts "InboxSync objects in memory:
ObjectSpace.each_object(Object) do |x|
if x.class.name.include?('InboxSync')
puts "#<#{x.class}:#{'0x%x' % (x.object_id << 1)}"
end
end
# in the sync handler invoked by the runner loop...
items = MailItem.find(@source_imap)
puts "mail items in memory:"
mail_item_count = ObjectSpace.each_object(InboxSync::MailItem) do |x|
if x.class.name.include?('InboxSync')
puts x.inspect
end
end
puts "mail item count: #{mail_item_count}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment