mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
Introduce support for dumping Rails process heap at the end of a benchmark run
This commit is contained in:
@ -18,4 +18,20 @@ class Admin::DiagnosticsController < Admin::AdminController
|
||||
content_type: Mime::TEXT
|
||||
|
||||
end
|
||||
|
||||
def dump_heap
|
||||
begin
|
||||
# ruby 2.1
|
||||
GC.start(full_mark: true)
|
||||
require 'objspace'
|
||||
|
||||
io = File.open("discourse-heap-#{SecureRandom.hex(3)}.json",'w')
|
||||
ObjectSpace.dump_all(:output => io)
|
||||
io.close
|
||||
|
||||
render text: "HEAP DUMP:\n#{io.path}", content_type: Mime::TEXT
|
||||
rescue
|
||||
render text: "HEAP DUMP:\nnot supported", content_type: Mime::TEXT
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user