21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# 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
|