|
|
|
@ -20,3 +20,20 @@ if ENV['MEMORY_REPORTING']
|
|
|
|
|
require 'rbtrace'
|
|
|
|
|
require 'memory_profiler'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
module CartoDB
|
|
|
|
|
def self.memory_dump(filename)
|
|
|
|
|
# Dump classes (id -> name)
|
|
|
|
|
cls = ObjectSpace.each_object.inject(Hash.new 0) { |h, o| h[o.class.object_id] = o.class.name; h }
|
|
|
|
|
File.open(filename + '.classes', 'w') do |f|
|
|
|
|
|
JSON.dump(cls, f)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
GC.start
|
|
|
|
|
|
|
|
|
|
# Dump objects
|
|
|
|
|
File.open(filename + '.dump', 'w') do |f|
|
|
|
|
|
ObjectSpace.dump_all(output: f)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|