Home Ruby Memory_profiling的使用,rails下面。
Post
Cancel

Ruby Memory_profiling的使用,rails下面。

参考 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!

This post is licensed under CC BY 4.0 by the author.