diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-26 02:34:23 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-26 02:34:23 +0000 |
commit | 6c458aec30a95695a3a7d20b6cf37fb4dbfd753a (patch) | |
tree | 99d1b70ddb350d87fa86104d36e60e1d8d320566 | |
parent | 59735e2c617df8e7d12b8bdf603915e105c9571a (diff) | |
download | ruby-6c458aec30a95695a3a7d20b6cf37fb4dbfd753a.tar.gz |
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | gc.c | 12 |
2 files changed, 19 insertions, 1 deletions
@@ -1,3 +1,11 @@ +Sat Oct 26 11:30:07 2013 Koichi Sasada <ko1@atdot.net> + + * 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@ruby-lang.org> * gc.c (gc_before_heap_sweep): Restructure code to mean clearly. @@ -5033,9 +5033,19 @@ vm_malloc_increase(rb_objspace_t *objspace, size_t new_size, size_t old_size, in } 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); + } + } } } |