从阅读文档开始:
似乎这些功能最初需要一些补丁,
对于分配:
https://github.com/ruby-prof/ruby-prof
对于内存使用:
http://rubyforge.org/tracker/index.php?func=detail&aid=11497&group_id=426&atid=1700
后者声称已适用。
这个github问题似乎支持这一点:
http://rubyforge.org/tracker/index.php?func=detail&aid=17676&group_id=1814&atid=7062
但在2.1.1安装中,我完全没有运气让这两种模式中的任何一种工作,例如:
require 'ruby-prof'
RubyProf.measure_mode = RubyProf::MEMORY
RubyProf.start
1000.times do
s = "string"
end
RubyProf::FlatPrinter.new(RubyProf.stop).print
生产:
Thread ID: 4183000
Fiber ID: 8413080
Total: 0.000000
Sort by: self_time
%self total self wait child calls name
NaN 0.000 0.000 0.000 0.000 1 Integer#times
NaN 0.000 0.000 0.000 0.000 1 Global#[No method]
我甚至尝试安装ruby 1.9.3来完成这个分析,但是rvm似乎找不到任何旧的补丁。有什么办法让它工作吗?或者这些功能已经被放弃了?
最佳答案
根据ruby教授的问题,我们需要一个补丁版本的ruby来使用内存分析器。
https://github.com/ruby-prof/ruby-prof/issues/166
https://github.com/skaes/rvm-patchsets