Class: Vernier::HeapTracker
- Inherits:
-
Object
- Object
- Vernier::HeapTracker
- Defined in:
- lib/vernier/heap_tracker.rb,
ext/vernier/heap_tracker.cc
Overview
Plan: The heap tracker can be in a few states:
* Idle
* Collecting
* Watching for new objects
* Watching for freed objects
* Draining
* Ignoring new objects
* Watching for freed objects
* Locked
* Ignoring new objects
* Ignoring freed objects
* Marking all existing objects (not yet implemented)
* N.B. This prevents any objects which the tracker has seen from being GC'd
Instance Attribute Summary collapse
-
#stack_table ⇒ Object
readonly
Returns the value of attribute stack_table.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#stack_table ⇒ Object (readonly)
Returns the value of attribute stack_table.
18 19 20 |
# File 'lib/vernier/heap_tracker.rb', line 18 def stack_table @stack_table end |
Class Method Details
.new(stack_table = StackTable.new) ⇒ Object
20 21 22 |
# File 'lib/vernier/heap_tracker.rb', line 20 def self.new(stack_table = StackTable.new) _new(stack_table) end |
.track(&block) ⇒ Object
28 29 30 31 32 |
# File 'lib/vernier/heap_tracker.rb', line 28 def self.track(&block) tracker = new tracker.track(&block) tracker end |
Instance Method Details
#inspect ⇒ Object
24 25 26 |
# File 'lib/vernier/heap_tracker.rb', line 24 def inspect "#<#{self.class} allocated_objects=#{allocated_objects} freed_objects=#{freed_objects} stack_table=#{stack_table.inspect}>" end |
#stack(obj) ⇒ Object
41 42 43 44 45 |
# File 'lib/vernier/heap_tracker.rb', line 41 def stack(obj) idx = stack_idx(obj) return nil unless idx stack_table.stack(idx) end |
#track ⇒ Object
34 35 36 37 38 39 |
# File 'lib/vernier/heap_tracker.rb', line 34 def track collect yield self ensure lock end |