diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-07 13:34:53 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-07 13:34:53 +0000 |
commit | 28221e3584c62482359aa9294d4b690d26cfb852 (patch) | |
tree | 9d52ccaf1d79c495496e983044dd48714a4fc3ab /gc.c | |
parent | 6c0822f0f5e934f6197f5a1be577764a74b30c7f (diff) |
merge revision(s) 39811: [Backport #8146]
* gc.c: Avoid unnecessary heap growth. patched by tmm1(Aman Gupta).
[Bug #8093] [ruby-core:53393]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@40176 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -225,6 +225,7 @@ typedef struct rb_objspace { struct heaps_free_bitmap *free_bitmap; RVALUE *range[2]; struct heaps_header *freed; + size_t marked_num; size_t free_num; size_t free_min; size_t final_num; @@ -1994,7 +1995,7 @@ after_gc_sweep(rb_objspace_t *objspace) inc = ATOMIC_SIZE_EXCHANGE(malloc_increase, 0); if (inc > malloc_limit) { malloc_limit += - (size_t)((inc - malloc_limit) * (double)objspace_live_num(objspace) / (heaps_used * HEAP_OBJ_LIMIT)); + (size_t)((inc - malloc_limit) * (double)objspace->heap.marked_num / (heaps_used * HEAP_OBJ_LIMIT)); if (malloc_limit < initial_malloc_limit) malloc_limit = initial_malloc_limit; } @@ -2067,7 +2068,7 @@ gc_prepare_free_objects(rb_objspace_t *objspace) gc_marks(objspace); before_gc_sweep(objspace); - if (objspace->heap.free_min > (heaps_used * HEAP_OBJ_LIMIT - objspace_live_num(objspace))) { + if (objspace->heap.free_min > (heaps_used * HEAP_OBJ_LIMIT - objspace->heap.marked_num)) { set_heaps_increment(objspace); } @@ -2555,6 +2556,7 @@ gc_mark_ptr(rb_objspace_t *objspace, VALUE ptr) register uintptr_t *bits = GET_HEAP_BITMAP(ptr); if (MARKED_IN_BITMAP(bits, ptr)) return 0; MARK_IN_BITMAP(bits, ptr); + objspace->heap.marked_num++; return 1; } @@ -2915,6 +2917,7 @@ gc_marks(rb_objspace_t *objspace) objspace->mark_func_data = 0; gc_prof_mark_timer_start(objspace); + objspace->heap.marked_num = 0; objspace->count++; SET_STACK_END; |