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.



105
106
107
108
109
110
111
# File 'lib/memory_tracker/gc_stat.rb', line 105

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

Instance Attribute Details

#statsObject (readonly)

Returns the value of attribute stats.



103
104
105
# File 'lib/memory_tracker/gc_stat.rb', line 103

def stats
  @stats
end

Instance Method Details

#customObject



113
114
115
116
117
118
119
120
121
122
# File 'lib/memory_tracker/gc_stat.rb', line 113

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[:heap_used]
  h[:in_use]    = @after[:total_allocated_object] - @after[:total_freed_object]
  h
end