mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-14 00:07:36 +02:00
Debug output for sizes of allocated objs
This commit is contained in:
parent
5112aa9f46
commit
07df5b03c5
1 changed files with 14 additions and 0 deletions
14
gc.c
14
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue