Project

General

Profile

ยซ Previous | Next ยป 

Revision 63583974

Added by peterzhu2118 (Peter Zhu) about 1 year ago

Fix leak of AST when Ripper#compile_error jumps

For example, the following script leaks:

class MyRipper < Ripper
  def initialize(src, &blk)
    super(src)
    @blk = blk
  end

  def compile_error(msg) = @blk.call(msg)
end

def call_parse = MyRipper.new("/") { |msg| return msg }.parse

10.times do
  100_000.times do
    call_parse
  end

  puts `ps -o rss= -p #{$$}`
end

Before:

93952
169040
244224
318784
394432
468224
544048
618560
693776
768384

After:

19776
19776
20352
20880
20912
21408
21328
21152
21472
20944