/* Walk heap jumping by size field of chunk header. Return an info record. * All data below highwater mark is considered busy as this routine * does not do liveness trace. */ Heap_Info get_heap_info() { void *p = heap; int busy = 0; int live = gc_num_live_objects(); int computed_busy_size = 0; int busy_size = (uint32_t)(next_free - heap); int free_size = (uint32_t)(end_of_heap - next_free + 1); while (p >= heap && p < next_free ) { // stay inbounds, walking heap // track busy++; computed_busy_size += ((heap_object *)p)->size; p = p + ((heap_object *)p)->size; } return (Heap_Info){heap, end_of_heap, next_free, (uint32_t)heap_size, busy, live, computed_busy_size, 0, busy_size, free_size }; }
Heap_Info get_heap_info() { void *p = start_of_heap; int busy = 0; int live = gc_num_live_objects(); int computed_busy_size = 0; //size of chunks was allocated int computed_free_size = 0; while ( p>=start_of_heap && p<alloc_bump_ptr ) { // stay inbounds, walking heap if (already_in_freelist((heap_object *)p)) { computed_free_size += ((heap_object *)p)->size; } else { busy++; computed_busy_size += ((heap_object *)p)->size; } p = p + ((heap_object *)p)->size; } computed_free_size += (uint32_t)(end_of_heap - alloc_bump_ptr + 1); return (Heap_Info){ start_of_heap, end_of_heap, alloc_bump_ptr,(uint32_t)heap_size, busy, live, computed_busy_size, computed_free_size,computed_busy_size,computed_free_size}; }