Class: QuartzTorrent::MemProfiler
- Inherits:
-
Object
- Object
- QuartzTorrent::MemProfiler
- Defined in:
- lib/quartz_torrent/memprofiler.rb
Overview
Utility class used for debugging memory leaks. It can be used to count the number of reachable instances of selected classes.
Instance Method Summary collapse
-
#getCounts ⇒ Object
Return a hashtable keyed by class where the value is the number of that class of object still reachable.
-
#initialize ⇒ MemProfiler
constructor
A new instance of MemProfiler.
-
#trackClass(clazz) ⇒ Object
Add a class to the list of classes we count the reachable instances of.
Constructor Details
#initialize ⇒ MemProfiler
Returns a new instance of MemProfiler.
6 7 8 |
# File 'lib/quartz_torrent/memprofiler.rb', line 6 def initialize @classes = [] end |
Instance Method Details
#getCounts ⇒ Object
Return a hashtable keyed by class where the value is the number of that class of object still reachable.
16 17 18 19 20 21 22 23 24 |
# File 'lib/quartz_torrent/memprofiler.rb', line 16 def getCounts result = {} @classes.each do |c| count = 0 ObjectSpace.each_object(c){ count += 1 } result[c] = count end result end |
#trackClass(clazz) ⇒ Object
Add a class to the list of classes we count the reachable instances of.
11 12 13 |
# File 'lib/quartz_torrent/memprofiler.rb', line 11 def trackClass(clazz) @classes.push clazz end |