improve formatting

This commit is contained in:
Sam 2015-02-10 15:59:08 +11:00
parent d5405eebde
commit 39e828dee4

View file

@ -48,14 +48,13 @@ class Admin::DiagnosticsController < Admin::AdminController
diff = from - to diff = from - to
report = "#{diff.length} objects have leaked\n"
require 'objspace' require 'objspace'
diff = diff.map do |id| diff = diff.map do |id|
ObjectSpace._id2ref(id) rescue nil ObjectSpace._id2ref(id) rescue nil
end.compact! end.compact!
report = "#{diff.length} objects have leaked\n"
report << "Summary:\n" report << "Summary:\n"
summary = {} summary = {}
@ -72,7 +71,7 @@ class Admin::DiagnosticsController < Admin::AdminController
"#{k}: #{v}" "#{k}: #{v}"
}.join("\n") }.join("\n")
report << "\nSample Items:\n" report << "\n\nSample Items:\n"
diff[0..5000].each do |v| diff[0..5000].each do |v|
report << "#{v.class}: #{String === v ? v[0..300] : (40 + ObjectSpace.memsize_of(v)).to_s + " bytes"}\n" rescue nil report << "#{v.class}: #{String === v ? v[0..300] : (40 + ObjectSpace.memsize_of(v)).to_s + " bytes"}\n" rescue nil