module MemoryProfiler
Public Class Methods
start(tag,n)
click to toggle source
@param [string] tag tag to add to dumped files @oaram [int] n dump every n seconds
# File lib/evoc/memory_profiler.rb, line 21 def self.start(tag,n) dump_dir = 'mem_dumps' index = "#{dump_dir}/#{tag}-index.txt" ObjectSpace.trace_object_allocations_start if !Dir.exists?(dump_dir) Dir.mkdir dump_dir end File.open(index,"w") @@thread = tick_every(n) do GC.start i = Time.now.strftime('%Y-%m-%dT%H:%M:%S') dump = "#{tag}-#{i}.dump" dump_path = "#{dump_dir}/#{dump}" ObjectSpace.dump_all(output: open(dump_path, "w")) File.open(index,'a') {|index| index.puts "#{dump_path},#{i}" } end end
stop()
click to toggle source
# File lib/evoc/memory_profiler.rb, line 39 def self.stop @@thread.kill end