Skip to content

Commit 96062ac

Browse files
ko1dbussink
authored andcommitted
* gc.c: change full GC timing to keep lower memory usage.
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
1 parent fff2d6d commit 96062ac

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

gc.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,9 @@ typedef struct rb_objspace {
541541
int parent_object_is_old;
542542

543543
int need_major_gc;
544+
545+
size_t last_major_gc;
546+
544547
size_t remembered_shady_object_count;
545548
size_t remembered_shady_object_limit;
546549
size_t old_object_count;
@@ -2998,15 +3001,13 @@ gc_after_sweep(rb_objspace_t *objspace)
29983001
(int)heap->total_slots, (int)heap_pages_swept_slots, (int)heap_pages_min_free_slots);
29993002

30003003
if (heap_pages_swept_slots < heap_pages_min_free_slots) {
3001-
heap_set_increment(objspace, heap_extend_pages(objspace));
3002-
heap_increment(objspace, heap);
3003-
3004-
#if USE_RGENGC
3005-
if (objspace->rgengc.remembered_shady_object_count + objspace->rgengc.old_object_count > (heap_pages_length * HEAP_OBJ_LIMIT) / 2) {
3006-
/* if [old]+[remembered shady] > [all object count]/2, then do major GC */
3007-
objspace->rgengc.need_major_gc = GPR_FLAG_MAJOR_BY_RESCAN;
3004+
if (objspace->rgengc.during_minor_gc && objspace->profile.count - objspace->rgengc.last_major_gc > 2 /* magic number */) {
3005+
objspace->rgengc.need_major_gc = GPR_FLAG_MAJOR_BY_NOFREE;
3006+
}
3007+
else {
3008+
heap_set_increment(objspace, heap_extend_pages(objspace));
3009+
heap_increment(objspace, heap);
30083010
}
3009-
#endif
30103011
}
30113012

30123013
gc_prof_set_heap_info(objspace);
@@ -4189,6 +4190,7 @@ gc_marks_body(rb_objspace_t *objspace, int full_mark)
41894190
}
41904191
else {
41914192
objspace->profile.major_gc_count++;
4193+
objspace->rgengc.last_major_gc = objspace->profile.count;
41924194
rgengc_mark_and_rememberset_clear(objspace, heap_eden);
41934195
}
41944196
#endif

0 commit comments

Comments
 (0)