Skip to content

Commit

Permalink
Add backtrace report for untracked disposals
Browse files Browse the repository at this point in the history
  • Loading branch information
wasnotrice committed May 7, 2014
1 parent cca311c commit c598346
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions lib/shoes/swt/leak_hunter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@
end.call

at_exit do
$callers.each do |k, v|
if v > 0
puts "#{v} => #{k}"
puts
end
count_for_class_and_backtrace = ->(hash) do
hash.map do |k, v|
if v > 0
"#{v} => #{k}"
end
end.compact.join("\n\n")
end

totals = ->(hash) do
Expand All @@ -69,9 +70,15 @@
end.compact.join("\n")
end

puts "Totals:"
puts "Undisposed resources:"
puts count_for_class_and_backtrace.call($callers)
puts
puts "Resources disposed without being tracked:"
puts count_for_class_and_backtrace.call($untracked_disposals)
puts
puts "Undisposed resource totals:"
puts totals.call($callers)
puts
puts "Untracked disposals:"
puts "Untracked disposal totals:"
puts totals.call($untracked_disposals)
end

0 comments on commit c598346

Please sign in to comment.