summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-21 05:17:40 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-21 05:17:40 +0000
commite35f127403979e2b61e38402155b1e5d94910c6a (patch)
tree471f2692b9bf788c4e1211eb3d94e09bc0182666 /gc.c
parent4a113cd3cb1eb33811532181a9c3f2cb0f666a09 (diff)
* 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
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c10
1 files changed, 7 insertions, 3 deletions
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