Question

I've been trying to get ruby-prof working for memory usage on Mac OS X w/ Ruby 1.8.7 and so far I'm not having much luck.

I understand from the documentation that RubyProf::MEMORY mode requires a patched version of Ruby. I've tried installing the GC-patched version (which I found referenced in the Rails documentation) through RVM:

rvm reinstall 1.8.7 --patch ruby187gc

Based on the output of this command, everything looks good. I clearly see "Applying patch 'ruby187gc'" in the console output.

The problem seems to come when trying to use an RVM gemset. I wrote the following script to test this:

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

When I preceed this script with rvm use 1.8.7 --patch ruby187gc, it creates the file "profile-graph.html" showing memory usage of all the different method calls in the script, as I'd expect. However, when I try something like rvm use 1.8.7@gemset_name --patch ruby187gc, the output file contains all "nan" values.

What gives? Is there some special trick to using a patched version of Ruby along with an RVM gemset? Does the problem lie elsewhere? I'm crossing my fingers and hoping that someone has run into a very similar problem and figured this out before.

Was it helpful?

Solution

Ah, I was overcomplicating things. Turns out I just needed to uninstall and reinstall the ruby-prof gem (after patching Ruby).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top