try monitoring used memory an GC by that

This commit is contained in:
Florian Staudacher 2012-04-05 22:21:30 +02:00
parent 21667768aa
commit fc941fa88b

View file

@ -11,7 +11,12 @@ class DeferredGarbageCollection
end end
def self.reconsider def self.reconsider
if DEFERRED_GC_THRESHOLD > 0 && Time.now - @@last_gc_run >= DEFERRED_GC_THRESHOLD mem = %x(free).split(" ")
percent_used = mem[8].to_i / (mem[7].to_i/100)
puts "percent memory used #{percent_used}" # just for info, as soon as we got some numbers remove it
if( (DEFERRED_GC_THRESHOLD > 0 && Time.now - @@last_gc_run >= DEFERRED_GC_THRESHOLD) || percent_used > 90 )
GC.enable GC.enable
GC.start GC.start
GC.disable GC.disable