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

ruby-changes:21351

From: nobu <ko1@a...>
Date: Tue, 4 Oct 2011 21:10:21 +0900 (JST)
Subject: [ruby-changes:21351] nobu:r33400 (trunk): * class.c (class_alloc): allocate extra memory after containing

nobu	2011-10-04 21:10:09 +0900 (Tue, 04 Oct 2011)

  New Revision: 33400

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

  Log:
    * class.c (class_alloc): allocate extra memory after containing
      object setup to get rid of rare-but-potential memory leak.
    * gc.c (gc_mark_children): skip marking extended members if ptr is
      NULL.

  Modified files:
    trunk/ChangeLog
    trunk/class.c
    trunk/gc.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 33399)
+++ ChangeLog	(revision 33400)
@@ -1,3 +1,11 @@
+Tue Oct  4 21:10:08 2011  Nobuyoshi Nakada  <nobu@r...>
+
+	* class.c (class_alloc): allocate extra memory after containing
+	  object setup to get rid of rare-but-potential memory leak.
+
+	* gc.c (gc_mark_children): skip marking extended members if ptr is
+	  NULL.
+
 Tue Oct  4 16:17:50 2011  NARUSE, Yui  <naruse@r...>
 
 	* lib/time.rb (Time.strptime): use Time.at if d[:seconds] is set.
Index: gc.c
===================================================================
--- gc.c	(revision 33399)
+++ gc.c	(revision 33400)
@@ -1824,6 +1824,7 @@
       case T_CLASS:
       case T_MODULE:
 	mark_m_tbl(objspace, RCLASS_M_TBL(obj), lev);
+	if (!RCLASS_EXT(obj)) break;
 	mark_tbl(objspace, RCLASS_IV_TBL(obj), lev);
 	mark_const_tbl(objspace, RCLASS_CONST_TBL(obj), lev);
 	ptr = RCLASS_SUPER(obj);
Index: class.c
===================================================================
--- class.c	(revision 33399)
+++ class.c	(revision 33400)
@@ -49,10 +49,9 @@
 static VALUE
 class_alloc(VALUE flags, VALUE klass)
 {
-    rb_classext_t *ext = ALLOC(rb_classext_t);
     NEWOBJ(obj, struct RClass);
     OBJSETUP(obj, klass, flags);
-    obj->ptr = ext;
+    obj->ptr = ALLOC(rb_classext_t);
     RCLASS_IV_TBL(obj) = 0;
     RCLASS_CONST_TBL(obj) = 0;
     RCLASS_M_TBL(obj) = 0;

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

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