diff options
author | nari <nari@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-18 12:44:55 +0000 |
---|---|---|
committer | nari <nari@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-18 12:44:55 +0000 |
commit | 1bc93a15912ab418bd54c0c064a47c557798eae9 (patch) | |
tree | 7dbe4ca58ec54f333bddc3178ad6715ba226c5ff /gc.c | |
parent | 03c7f0ca43a65b18d81387f82bf91e5d5bc14bee (diff) | |
download | ruby-1bc93a15912ab418bd54c0c064a47c557798eae9.tar.gz |
* 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/trunk@39811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -228,6 +228,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; @@ -2001,7 +2002,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; } @@ -2074,7 +2075,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); } @@ -2562,6 +2563,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; } @@ -2922,6 +2924,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; |