Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory allocations reported on wrong line for blocks in Ruby 2.6.x #87

Open
jturkel opened this issue Jun 9, 2020 · 1 comment
Open

Comments

@jturkel
Copy link

jturkel commented Jun 9, 2020

The following test case reports the allocation of method arguments on different lines for Ruby MRI 2.5/2.7 vs. Ruby MRI 2.6:

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'memory_profiler', '0.9.14'
end

puts "Ruby: #{RUBY_VERSION}"

def do_something
  yield
end

def do_something_else(options)
  yield
end

report = MemoryProfiler.report do
  100_000.times do
    do_something do
      do_something_else({foo: 1, bar: 2, baz: 3}) do
        # no-op
      end
    end
  end
end

report.pretty_print(retained_strings: 0, allocated_strings: 0)

Running this in Ruby 2.5 and 2.7 reports 100,000 allocations on the do_something_else({foo: 1, bar: 2, baz: 3}) line as expected. Ruby 2.6 incorrectly reports the allocations on the do_something line.

@SamSaffron
Copy link
Owner

Seems super likely you landed on a Ruby regression here that got fixed. Not sure if there is anything we can do here, we get the line numbers directly from MRI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants