From e35f127403979e2b61e38402155b1e5d94910c6a Mon Sep 17 00:00:00 2001 From: ko1 Date: Fri, 21 Jun 2013 05:17:40 +0000 Subject: * gc.c: fix to use total_allocated_object_num and heaps_used at the GC time for profiler. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- gc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'gc.c') diff --git a/gc.c b/gc.c index f8b6305647..659b0bac9d 100644 --- a/gc.c +++ b/gc.c @@ -355,6 +355,8 @@ typedef struct rb_objspace { /* temporary profiling space */ double gc_sweep_start_time; + size_t total_allocated_object_num_at_gc_start; + size_t heaps_used_at_gc_start; } profile; struct gc_list *global_list; size_t count; @@ -3957,6 +3959,8 @@ garbage_collect_body(rb_objspace_t *objspace, int full_mark, int immediate_sweep if (GC_NOTIFY) fprintf(stderr, "start garbage_collect(%d, %d, %d)\n", full_mark, immediate_sweep, reason); objspace->count++; + objspace->profile.total_allocated_object_num_at_gc_start = objspace->total_allocated_object_num; + objspace->profile.heaps_used_at_gc_start = heaps_used; gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_START, 0 /* TODO: pass minor/immediate flag? */); gc_prof_timer_start(objspace, reason | (minor_gc ? GPR_FLAG_MINOR : 0)); @@ -5099,11 +5103,11 @@ gc_prof_set_malloc_info(rb_objspace_t *objspace) static inline void gc_prof_set_heap_info(rb_objspace_t *objspace, gc_profile_record *record) { - size_t live = objspace_live_num(objspace); - size_t total = heaps_used * HEAP_OBJ_LIMIT; + size_t live = objspace->profile.total_allocated_object_num_at_gc_start - objspace->total_freed_object_num; + size_t total = objspace->profile.heaps_used_at_gc_start * HEAP_OBJ_LIMIT; #if GC_PROFILE_MORE_DETAIL - record->heap_use_slots = heaps_used; + record->heap_use_slots = objspace->profile.heaps_used_at_gc_start; record->heap_live_objects = live; record->heap_free_objects = total - live; #endif -- cgit v1.2.3