【问题标题】:Is there a trick to profiling memory usage w/ ruby-prof using an rvm gemset?使用 rvm gemset 分析内存使用情况是否有技巧?
【发布时间】:2012-11-21 18:42:50
【问题描述】:

我一直在尝试让ruby-prof 在带有 Ruby 1.8.7 的 Mac OS X 上为内存使用工作,但到目前为止我运气不佳。

我从文档中了解到RubyProf::MEMORY 模式requires a patched version of Ruby。我已经尝试通过 RVM 安装 GC 补丁版本(我在 the Rails documentation 中找到了引用):

rvm reinstall 1.8.7 --patch ruby187gc

根据此命令的输出,一切看起来都不错。我在控制台输出中清楚地看到“正在应用补丁 'ruby187gc'”。

在尝试使用 RVM gemset 时似乎出现了问题。我编写了以下脚本来测试:

require "ruby-prof"

RubyProf.measure_mode = RubyProf::MEMORY
results = RubyProf.profile do
    # code to measure
end

File.open(File.join(File.dirname(__FILE__), "profile-graph.html"), "w") do |file|
  RubyProf::GraphHtmlPrinter.new(results).print(file)
end

当我在这个脚本之前加上rvm use 1.8.7 --patch ruby187gc 时,它会创建文件“profile-graph.html”,显示脚本中所有不同方法调用的内存使用情况,正如我所期望的那样。然而,当我尝试像rvm use 1.8.7@gemset_name --patch ruby187gc 这样的东西时,输出文件包含所有“nan”值。

什么给了?使用修补版本的 Ruby 和 RVM gemset 有什么特别的技巧吗?问题出在其他地方吗?我正在祈祷,希望有人遇到过非常相似的问题并且以前解决过这个问题。

【问题讨论】:

    标签: ruby rvm ruby-1.8.7 ruby-prof gemset


    【解决方案1】:

    啊,我把事情复杂化了。结果我只需要uninstall and reinstall ruby​​-prof gem(在修补 Ruby 之后)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-09
      • 2011-02-25
      • 2012-03-07
      • 2011-03-26
      • 2013-06-20
      • 2015-08-24
      • 2013-05-30
      相关资源
      最近更新 更多