[前][次][番号順一覧][スレッド一覧]

ruby-changes:37009

From: normal <ko1@a...>
Date: Thu, 1 Jan 2015 11:18:57 +0900 (JST)
Subject: [ruby-changes:37009] normal:r49090 (trunk): symbol.c: fix memory leak from global fstr hash

normal	2015-01-01 11:18:40 +0900 (Thu, 01 Jan 2015)

  New Revision: 49090

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49090

  Log:
    symbol.c: fix memory leak from global fstr hash
    
    * symbol.c (rb_gc_free_dsymbol): delete from global fstr hash
    * test/ruby/test_symbol.rb (test_symbol_fstr_leak): test for bug
      [ruby-core:67268] [Bug #10686]

  Modified files:
    trunk/ChangeLog
    trunk/symbol.c
    trunk/test/ruby/test_symbol.rb
Index: symbol.c
===================================================================
--- symbol.c	(revision 49089)
+++ symbol.c	(revision 49090)
@@ -664,6 +664,7 @@ rb_gc_free_dsymbol(VALUE sym) https://github.com/ruby/ruby/blob/trunk/symbol.c#L664
     if (str) {
 	RSYMBOL(sym)->fstr = 0;
 	unregister_sym(str, sym);
+	rb_hash_delete_entry(global_symbols.dsymbol_fstr_hash, str);
     }
 }
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49089)
+++ ChangeLog	(revision 49090)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jan  1 11:07:12 2015  Eric Wong  <e@8...>
+
+	* symbol.c (rb_gc_free_dsymbol): delete from global fstr hash
+	* test/ruby/test_symbol.rb (test_symbol_fstr_leak): test for bug
+	  [ruby-core:67268] [Bug #10686]
+
 Thu Jan  1 09:14:21 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* vm_args.c (keyword_hash_p): fix non-symbol keys hash.
Index: test/ruby/test_symbol.rb
===================================================================
--- test/ruby/test_symbol.rb	(revision 49089)
+++ test/ruby/test_symbol.rb	(revision 49090)
@@ -230,4 +230,12 @@ class TestSymbol < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_symbol.rb#L230
     end
     assert_nothing_raised(NoMethodError, bug10259) {obj.send("unagi=".intern, 1)}
   end
+
+  def test_symbol_fstr_leak
+    bug10686 = '[ruby-core:67268] [Bug #10686]'
+    x = 0
+    assert_no_memory_leak([], '', <<-"end;", bug10686)
+      200_000.times { |i| i.to_s.to_sym }
+    end;
+  end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]