Class: MemoryTracker::GcStatDelta

Inherits:
Object
  • Object
show all
Defined in:
lib/memory_tracker/gc_stat.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(before, after) ⇒ GcStatDelta

Returns a new instance of GcStatDelta.



44
45
46
47
48
49
50
# File 'lib/memory_tracker/gc_stat.rb', line 44

def initialize(before, after)
  @after = after
  @stats = after.stats.inject({}) do |h, (k, v)|
    h[k] = after.stats[k] - before.stats[k]
    h
  end
end

Instance Attribute Details

#statsObject (readonly)

Returns the value of attribute stats.



42
43
44
# File 'lib/memory_tracker/gc_stat.rb', line 42

def stats
  @stats
end

Instance Method Details

#customObject



52
53
54
55
56
57
58
59
60
61
# File 'lib/memory_tracker/gc_stat.rb', line 52

def custom
  return unless stats[:total_allocated_object] && stats[:total_freed_object]
  h = {}
  h[:total_allocated_object] = stats[:total_allocated_object]
  h[:count] = stats[:count]
  h[:rss] = stats[:rss]
  h[:heap_used] = @after.stats[:heap_used]
  h[:in_use]    = @after.stats[:total_allocated_object] - @after.stats[:total_freed_object]
  h
end