class BusyAdministrator::MemoryUtils::MemoryAnalyzer
Attributes
pairs[R]
Public Class Methods
new()
click to toggle source
# File lib/busy-administrator/memory_utils.rb, line 6 def initialize @pairs = [] end
Public Instance Methods
analyze(verbose: false)
click to toggle source
# File lib/busy-administrator/memory_utils.rb, line 14 def analyze(verbose: false) output = {} @pairs.each do |pair| key, value = pair target = ObjectSpace._id2ref(value) if target.is_a?(Class) || target.is_a?(Module) output[key.to_sym] = MemorySize.of_all_objects_from(target) else output[key.to_sym] = MemorySize.of(target) end log("#{ key } = #{ output[key.to_sym] } { #{ target.class } }", verbose: verbose) end output end
include(key:, value:)
click to toggle source
# File lib/busy-administrator/memory_utils.rb, line 10 def include(key:, value:) @pairs << [key, value.object_id] end
Private Instance Methods
log(message, verbose: false)
click to toggle source
# File lib/busy-administrator/memory_utils.rb, line 36 def log(message, verbose: false) if verbose puts "[BusyAdministrator::MemoryUtils::Analyzer.analyze] #{ message }" end end