Back

ruby - memory_profiling 的使用, rails下面。

发布时间: 2019-06-07 21:40:00

参考 https://gist.github.com/os6sense/35b9e37eb8f23bdb4a81cde1cc23aa03

add to gemfile :

gem 'memory_profiler', require: true, github: 'SamSaffron/memory_profiler'

Add a config/initializer/memory_profiler.rb as follows:

MemoryProfiler.start
at_exit do
  report = MemoryProfiler.stop
  report.pretty_print
end

This uses a LOT of memory - its the first time I've wanted 128/256GB. Its also VERY slow to generate the report on termination - be patient!

Back