简体   繁体   中英

Debugging Ruby on Rails app 1.9.2

I have been using Ruby debugger and want to be able to get stack dumps from irb. How can I get garbage collection dumps?
Also what patch should I use to be able to tweak the garbage collector a bit?

In Ruby you can re-open classes at any point and redefine them if you want. So you could re-open the GC class and add dumps or redefine any methods you want. You also create aliases of existing methods so that you could call them again later. For example. if you had a class Foo with a method bar that you wanted to add some functionality to, you could do something like:

class Foo
  alias :original_bar :bar
  def bar
    # do something new
    original_bar
  end
end

So you take the original bar method and alias it to original_bar , then re-open bar and insert your custom code, then reference the original bar method again. BEHOLD THE POWER OF RUBY!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM