ruby-changes:31345
From: ko1 <ko1@a...>
Date: Sat, 26 Oct 2013 11:34:32 +0900 (JST)
Subject: [ruby-changes:31345] ko1:r43424 (trunk): * gc.c (vm_malloc_increase): do gc_rest_sweep() before GC.
ko1 2013-10-26 11:34:23 +0900 (Sat, 26 Oct 2013) New Revision: 43424 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43424 Log: * gc.c (vm_malloc_increase): do gc_rest_sweep() before GC. gc_rest_sweep() can reduce malloc_increase, so try it before GC. Otherwise, malloc_increase can be less than malloc_limit at gc_before_sweep(). This means that re-calculation of malloc_limit may be wrong value. Modified files: trunk/ChangeLog trunk/gc.c Index: ChangeLog =================================================================== --- ChangeLog (revision 43423) +++ ChangeLog (revision 43424) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Oct 26 11:30:07 2013 Koichi Sasada <ko1@a...> + + * gc.c (vm_malloc_increase): do gc_rest_sweep() before GC. + gc_rest_sweep() can reduce malloc_increase, so try it before GC. + Otherwise, malloc_increase can be less than malloc_limit at + gc_before_sweep(). This means that re-calculation of malloc_limit + may be wrong value. + Sat Oct 26 06:35:41 2013 Masaya Tarui <tarui@r...> * gc.c (gc_before_heap_sweep): Restructure code to mean clearly. Index: gc.c =================================================================== --- gc.c (revision 43423) +++ gc.c (revision 43424) @@ -5033,9 +5033,19 @@ vm_malloc_increase(rb_objspace_t *objspa https://github.com/ruby/ruby/blob/trunk/gc.c#L5033 } if (do_gc) { - if ((ruby_gc_stress && !ruby_disable_gc_stress) || (malloc_increase > malloc_limit)) { + if (ruby_gc_stress && !ruby_disable_gc_stress) { garbage_collect_with_gvl(objspace, 0, 0, GPR_FLAG_MALLOC); } + else { + retry: + if (malloc_increase > malloc_limit) { + if (is_lazy_sweeping(heap_eden)) { + gc_rest_sweep(objspace); /* rest_sweep can reduce malloc_increase */ + goto retry; + } + garbage_collect_with_gvl(objspace, 0, 0, GPR_FLAG_MALLOC); + } + } } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/