diff --git a/gc.c b/gc.c index 064b5b4e..f08e8008 100644 --- a/gc.c +++ b/gc.c @@ -88,6 +88,10 @@ static struct ck_malloc my_allocator = { }; #if GC_DEBUG_TRACE +const int NUM_ALLOC_SIZES = 10; +static double allocated_size_counts[10] = { + 0,0,0,0,0, + 0,0,0,0,0}; static double allocated_obj_counts[25] = { 0,0,0,0,0, 0,0,0,0,0, @@ -100,6 +104,11 @@ static double allocated_heap_counts[4] = {0, 0, 0, 0}; void print_allocated_obj_counts() { int i; + fprintf(stderr, "Allocated sizes:\n"); + fprintf(stderr, "Size, Allocations\n"); + for (i = 0; i < NUM_ALLOC_SIZES; i++){ + fprintf(stderr, "%d, %lf\n", 32 + (i*32), allocated_size_counts[i]); + } fprintf(stderr, "Allocated objects:\n"); fprintf(stderr, "Tag, Allocations\n"); for (i = 0; i < 25; i++){ @@ -643,6 +652,11 @@ void *gc_try_alloc(gc_heap * h, int heap_type, size_t size, char *obj, if (heap_type != HEAP_HUGE) { // Copy object into heap now to avoid any uninitialized memory issues + #if GC_DEBUG_TRACE + if (size < (32 * NUM_ALLOC_SIZES)) { + allocated_size_counts[(size / 32) - 1]++; + } + #endif gc_copy_obj(f2, obj, thd); //h->free_size -= gc_allocated_bytes(obj, NULL, NULL); ck_pr_sub_ptr(&(thd->cached_heap_free_sizes[heap_type]), size);