Created
June 7, 2012 21:00
-
-
Save kellyredding/2891503 to your computer and use it in GitHub Desktop.
ruby `ObjectSpace` usage from debugging a memory leak in inbox-sync
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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