class Fluent::GcInput

Attributes

last_checked[RW]

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_gc.rb, line 16
def configure(conf)
  super

  @interval = @interval.to_i
end
shutdown() click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_gc.rb, line 28
def shutdown
  super
  @watcher.terminate
  @watcher.join
end
start() click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_gc.rb, line 22
def start
  super
  GC.disable if @disable
  @watcher = Thread.new(&method(:watcher))
end
start_gc() click to toggle source
# File lib/fluent/plugin/in_gc.rb, line 51
def start_gc
  log.info "gc: before #{GC.stat}" if @debug # intentionally info level
  disabled = GC.enable
  GC.start
  GC.disable if disabled
  log.info "gc: after  #{GC.stat}" if @debug
end
watcher() click to toggle source

thread callback

# File lib/fluent/plugin/in_gc.rb, line 35
def watcher
  @last_checked = Fluent::Engine.now
  while true
    sleep 0.5
    begin
      if Fluent::Engine.now - @last_checked >= @interval
        now = Fluent::Engine.now
        start_gc
        @last_checked = now
      end
    rescue => e
      log.warn "#{e.class} #{e.message} #{e.backtrace.first}"
    end
  end
end