Module: Memstat::OobGC::Unicorn

Defined in:
lib/memstat/oob_gc/unicorn.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(app, threshold = (1024**3)) ⇒ Object



4
5
6
7
# File 'lib/memstat/oob_gc/unicorn.rb', line 4

def self.new(app, threshold = (1024**3))
  self.const_set :OOBGC_THRESHOLD, threshold
  app # pretend to be Rack middleware since it was in the past
end

Instance Method Details

#process_client(client) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/memstat/oob_gc/unicorn.rb', line 9

def process_client(client)
  super(client) # Unicorn::HttpServer#process_client
  status = Memstat::Proc::Status.new(:pid => Process.pid)

  if status.rss > OOBGC_THRESHOLD
    GC.start
  end
end