Class: GCStats

Inherits:
Object
  • Object
show all
Extended by:
Yarv
Includes:
Singleton
Defined in:
lib/madvertise/gc_stats.rb

Defined Under Namespace

Modules: Yarv

Class Method Summary collapse

Methods included from Yarv

clear, count_allocations, count_collections, count_objects, enable, gather

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/madvertise/gc_stats.rb', line 45

def self.available?
  respond_to?(:gather)
end

.start!Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/madvertise/gc_stats.rb', line 49

def self.start!
  if available?
    enable
    $log.info("gc:stats", enabled: true)

    EventMachine.next_tick do
      EventMachine::PeriodicTimer.new(60*60) do
        GC.start
      end

      EventMachine::PeriodicTimer.new(60) do
        gather
        clear
      end
    end
  else
    $log.info("gc:stats", enabled: false)
  end
end