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

ruby-changes:35676

From: normal <ko1@a...>
Date: Thu, 2 Oct 2014 05:36:49 +0900 (JST)
Subject: [ruby-changes:35676] normal:r47758 (trunk): io.c (fptr_finalize): free memory before GC sweep

normal	2014-10-02 05:36:28 +0900 (Thu, 02 Oct 2014)

  New Revision: 47758

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

  Log:
    io.c (fptr_finalize): free memory before GC sweep
    
    This releases memory on explict calls to rb_io_close,
    reducing pressure on the GC.
    
    Final massif snapshot shows reduced heap usage after RubyGems load
    (valgrind --tool=massif ./ruby -e exit)
    
    before:
    mem_heap_B=4821992
    mem_heap_extra_B=1302952
    
    after:
    mem_heap_B=4791056
    mem_heap_extra_B=1192440

  Modified files:
    trunk/ChangeLog
    trunk/io.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47757)
+++ ChangeLog	(revision 47758)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Oct  2 05:32:17 2014  Eric Wong  <e@8...>
+
+	* io.c (fptr_finalize): free memory before GC sweep
+	  [ruby-core:65269] [Feature #10295]
+
 Thu Oct  2 05:27:24 2014  Eric Wong  <e@8...>
 
 	* marshal.c (w_class): check dump_arg->compat_tbl before lookup
Index: io.c
===================================================================
--- io.c	(revision 47757)
+++ io.c	(revision 47758)
@@ -4251,6 +4251,9 @@ maygvl_fclose(FILE *file, int keepgvl) https://github.com/ruby/ruby/blob/trunk/io.c#L4251
     return (int)(intptr_t)rb_thread_call_without_gvl(nogvl_fclose, file, RUBY_UBF_IO, 0);
 }
 
+static void free_io_buffer(rb_io_buffer_t *buf);
+static void clear_codeconv(rb_io_t *fptr);
+
 static void
 fptr_finalize(rb_io_t *fptr, int noraise)
 {
@@ -4312,6 +4315,9 @@ fptr_finalize(rb_io_t *fptr, int noraise https://github.com/ruby/ruby/blob/trunk/io.c#L4315
             rb_exc_raise(err);
         }
     }
+    free_io_buffer(&fptr->rbuf);
+    free_io_buffer(&fptr->wbuf);
+    clear_codeconv(fptr);
 }
 
 static void

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

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