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

ruby-changes:4895

From: ko1@a...
Date: Mon, 12 May 2008 15:29:01 +0900 (JST)
Subject: [ruby-changes:4895] akr - Ruby:r16388 (trunk): * gc.c (ruby_vm_xmalloc): increase malloc_increase only if malloc

akr	2008-05-12 15:28:43 +0900 (Mon, 12 May 2008)

  New Revision: 16388

  Modified files:
    trunk/ChangeLog
    trunk/gc.c

  Log:
    * gc.c (ruby_vm_xmalloc): increase malloc_increase only if malloc
      succeeds.  failed malloc size can be huge.  it may increase
      malloc_limit too big which cause less GC and memory full.
      (ruby_vm_xrealloc): ditto.
      (rb_objspace): make params.limit and params.increase size_t.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16388&r2=16387&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/gc.c?r1=16388&r2=16387&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 16387)
+++ ChangeLog	(revision 16388)
@@ -1,3 +1,11 @@
+Mon May 12 15:20:02 2008  Tanaka Akira  <akr@f...>
+
+	* gc.c (ruby_vm_xmalloc): increase malloc_increase only if malloc
+	  succeeds.  failed malloc size can be huge.  it may increase
+	  malloc_limit too big which cause less GC and memory full.
+	  (ruby_vm_xrealloc): ditto.
+	  (rb_objspace): make params.limit and params.increase size_t.
+
 Mon May 12 15:04:58 2008  Yukihiro Matsumoto  <matz@r...>
 
 	* re.c (rb_reg_prepare_re): made non static with small refactoring.
Index: gc.c
===================================================================
--- gc.c	(revision 16387)
+++ gc.c	(revision 16388)
@@ -145,8 +145,8 @@
 
 typedef struct rb_objspace {
     struct {
-	unsigned long limit;
-	unsigned long increase;
+	size_t limit;
+	size_t increase;
     } params;
     struct {
 	size_t increment;
@@ -314,9 +314,8 @@
 	rb_raise(rb_eNoMemError, "negative allocation size (or too big)");
     }
     if (size == 0) size = 1;
-    malloc_increase += size;
 
-    if (ruby_gc_stress || malloc_increase > malloc_limit) {
+    if (ruby_gc_stress || (malloc_increase+size) > malloc_limit) {
 	garbage_collect(objspace);
     }
     RUBY_CRITICAL(mem = malloc(size));
@@ -328,6 +327,7 @@
 	    rb_memerror();
 	}
     }
+    malloc_increase += size;
 
     return mem;
 }
@@ -381,7 +381,6 @@
     }
     if (!ptr) return ruby_xmalloc(size);
     if (size == 0) size = 1;
-    malloc_increase += size;
     if (ruby_gc_stress) garbage_collect(objspace);
     RUBY_CRITICAL(mem = realloc(ptr, size));
     if (!mem) {
@@ -392,6 +391,7 @@
 	    rb_memerror();
         }
     }
+    malloc_increase += size;
 
     return mem;
 }

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

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