Skip to content

Commit

Permalink
* gc.c: change full GC timing to keep lower memory usage.
Browse files Browse the repository at this point in the history
  Extend heap only at
  (1) after major GC
  or
  (2) after several (two times, at current) minor GC
  Details in https://bugs.ruby-lang.org/issues/9607#note-9
  [Bug ruby#9607]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Conflicts:
	ChangeLog
	gc.c
  • Loading branch information
ko1 authored and dbussink committed Jun 13, 2014
1 parent fff2d6d commit 96062ac
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,9 @@ typedef struct rb_objspace {
int parent_object_is_old;

int need_major_gc;

size_t last_major_gc;

size_t remembered_shady_object_count;
size_t remembered_shady_object_limit;
size_t old_object_count;
Expand Down Expand Up @@ -2998,15 +3001,13 @@ gc_after_sweep(rb_objspace_t *objspace)
(int)heap->total_slots, (int)heap_pages_swept_slots, (int)heap_pages_min_free_slots);

if (heap_pages_swept_slots < heap_pages_min_free_slots) {
heap_set_increment(objspace, heap_extend_pages(objspace));
heap_increment(objspace, heap);

#if USE_RGENGC
if (objspace->rgengc.remembered_shady_object_count + objspace->rgengc.old_object_count > (heap_pages_length * HEAP_OBJ_LIMIT) / 2) {
/* if [old]+[remembered shady] > [all object count]/2, then do major GC */
objspace->rgengc.need_major_gc = GPR_FLAG_MAJOR_BY_RESCAN;
if (objspace->rgengc.during_minor_gc && objspace->profile.count - objspace->rgengc.last_major_gc > 2 /* magic number */) {
objspace->rgengc.need_major_gc = GPR_FLAG_MAJOR_BY_NOFREE;
}
else {
heap_set_increment(objspace, heap_extend_pages(objspace));
heap_increment(objspace, heap);
}
#endif
}

gc_prof_set_heap_info(objspace);
Expand Down Expand Up @@ -4189,6 +4190,7 @@ gc_marks_body(rb_objspace_t *objspace, int full_mark)
}
else {
objspace->profile.major_gc_count++;
objspace->rgengc.last_major_gc = objspace->profile.count;
rgengc_mark_and_rememberset_clear(objspace, heap_eden);
}
#endif
Expand Down

0 comments on commit 96062ac

Please sign in to comment.