Class: DeferredGarbageCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/kameleon/ext/ruby/deferred_garbage_collector.rb

Overview

Constant Summary collapse

DEFERRED_GC_THRESHOLD =
(ENV['DEFER_GC'] || 10.0).to_f
@@last_gc_run =
Time.now

Class Method Summary collapse

Class Method Details

.reconsiderObject



12
13
14
15
16
17
18
19
# File 'lib/kameleon/ext/ruby/deferred_garbage_collector.rb', line 12

def self.reconsider
  if DEFERRED_GC_THRESHOLD > 0 && Time.now - @@last_gc_run >= DEFERRED_GC_THRESHOLD
    GC.enable
    GC.start
    GC.disable
    @@last_gc_run = Time.now
  end
end

.startObject



8
9
10
# File 'lib/kameleon/ext/ruby/deferred_garbage_collector.rb', line 8

def self.start
  GC.disable if DEFERRED_GC_THRESHOLD > 0
end