Skip to content
  • NARUSE, Yui's avatar
    23bfe621
    merge revision(s) b14674b2: [Backport #20194] (#10295) · 23bfe621
    NARUSE, Yui authored
    Memory leak with TracePoint on bmethod
    
    	[Bug #20194]
    
    	When disabling the TracePoint on bmethod, the hooks list is not freed.
    
    	For example:
    
    	    obj = Object.new
    	    obj.define_singleton_method(:foo) {}
    	    bmethod = obj.method(:foo)
    	    tp = TracePoint.new(:return) {}
    
    	    10.times do
    	      100_000.times do
    	        tp.enable(target: bmethod) {}
    	      end
    
    	      puts `ps -o rss= -p #{$$}`
    	    end
    
    	Before:
    
    	    18208
    	    22832
    	    26528
    	    29728
    	    34000
    	    37776
    	    40864
    	    44400
    	    47680
    	    51504
    
    	After:
    
    	    16688
    	    17168
    	    17168
    	    17248
    	    17696
    	    17760
    	    17824
    	    17824
    	    17856
    	    17920
    	---
    	 test/ruby/test_settracefunc.rb | 13 +++++++++++++
    	 vm_trace.c                     |  1 +
    	 2 files changed, 14 insertions(+)
    23bfe621
    merge revision(s) b14674b2: [Backport #20194] (#10295)
    NARUSE, Yui authored
    Memory leak with TracePoint on bmethod
    
    	[Bug #20194]
    
    	When disabling the TracePoint on bmethod, the hooks list is not freed.
    
    	For example:
    
    	    obj = Object.new
    	    obj.define_singleton_method(:foo) {}
    	    bmethod = obj.method(:foo)
    	    tp = TracePoint.new(:return) {}
    
    	    10.times do
    	      100_000.times do
    	        tp.enable(target: bmethod) {}
    	      end
    
    	      puts `ps -o rss= -p #{$$}`
    	    end
    
    	Before:
    
    	    18208
    	    22832
    	    26528
    	    29728
    	    34000
    	    37776
    	    40864
    	    44400
    	    47680
    	    51504
    
    	After:
    
    	    16688
    	    17168
    	    17168
    	    17248
    	    17696
    	    17760
    	    17824
    	    17824
    	    17856
    	    17920
    	---
    	 test/ruby/test_settracefunc.rb | 13 +++++++++++++
    	 vm_trace.c                     |  1 +
    	 2 files changed, 14 insertions(+)
Loading