class QuartzTorrent::MemProfiler

Utility class used for debugging memory leaks. It can be used to count the number of reachable instances of selected classes.

Public Class Methods

new() click to toggle source
# File lib/quartz_torrent/memprofiler.rb, line 6
def initialize
  @classes = []
end

Public Instance Methods

getCounts() click to toggle source

Return a hashtable keyed by class where the value is the number of that class of object still reachable.

# 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) click to toggle source

Add a class to the list of classes we count the reachable instances of.

# File lib/quartz_torrent/memprofiler.rb, line 11
def trackClass(clazz)
  @classes.push clazz
end