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

ruby-changes:40593

From: ko1 <ko1@a...>
Date: Thu, 19 Nov 2015 21:57:35 +0900 (JST)
Subject: [ruby-changes:40593] ko1:r52672 (trunk): * gc.c (gc_start): force to invoke GC by GC.start

ko1	2015-11-19 21:57:20 +0900 (Thu, 19 Nov 2015)

  New Revision: 52672

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

  Log:
    * gc.c (gc_start): force to invoke GC by GC.start
      even if it is GC.disable'd.
    
    * test/ruby/test_gc.rb: add a test.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
    trunk/test/ruby/test_gc.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52671)
+++ ChangeLog	(revision 52672)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Nov 19 21:55:11 2015  Koichi Sasada  <ko1@a...>
+
+	* gc.c (gc_start): force to invoke GC by GC.start
+	  even if it is GC.disable'd.
+
+	* test/ruby/test_gc.rb: add a test.
+
 Thu Nov 19 20:08:59 2015  Koichi Sasada  <ko1@a...>
 
 	* gc.c: trivial performance improvements.
Index: gc.c
===================================================================
--- gc.c	(revision 52671)
+++ gc.c	(revision 52672)
@@ -6158,8 +6158,8 @@ gc_start(rb_objspace_t *objspace, const https://github.com/ruby/ruby/blob/trunk/gc.c#L6158
     int do_full_mark = full_mark;
     objspace->flags.immediate_sweep = immediate_sweep;
 
-    if (!heap_allocated_pages) return FALSE;      /* heap is not ready */
-    if (!ready_to_gc(objspace)) return TRUE; /* GC is not allowed */
+    if (!heap_allocated_pages) return FALSE; /* heap is not ready */
+    if (reason != GPR_FLAG_METHOD && !ready_to_gc(objspace)) return TRUE; /* GC is not allowed */
 
     if (RGENGC_CHECK_MODE) {
 	assert(objspace->flags.stat == gc_stat_none);
Index: test/ruby/test_gc.rb
===================================================================
--- test/ruby/test_gc.rb	(revision 52671)
+++ test/ruby/test_gc.rb	(revision 52672)
@@ -385,4 +385,15 @@ class TestGc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_gc.rb#L385
       C.new
     end;
   end
+
+  def test_gc_disabled_start
+    begin
+      disabled = GC.disable
+      c = GC.count
+      GC.start
+      assert_equal 1, GC.count - c
+    ensure
+      GC.enable unless disabled
+    end
+  end
 end

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

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