From b02120b386af0ff8791a48f4eff062736b5d5aa0 Mon Sep 17 00:00:00 2001 From: Nicolas Cannasse Date: Wed, 18 Oct 2023 12:03:00 +0200 Subject: [PATCH] added HL_GC_PROFILE_MEM --- src/allocator.c | 18 ++++++++++++++++++ src/gc.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/src/allocator.c b/src/allocator.c index bacbafc34..089f3a3d1 100644 --- a/src/allocator.c +++ b/src/allocator.c @@ -441,6 +441,24 @@ static void gc_flush_empty_pages() { } } +static int64 gc_allocator_private_memory() { + return free_lists_size; +} + +static int gc_free_memory( gc_pheader *ph ) { + gc_allocator_page_data *p = &ph->alloc; + if( p->need_flush ) + flush_free_list(ph); + gc_freelist *fl = &p->free; + int k; + int free = 0; + for(k=fl->current;kcount;k++) { + gc_fl *c = GET_FL(fl,k); + free += c->count * p->block_size; + } + return free; +} + #ifdef GC_DEBUG static void gc_clear_unmarked_mem() { int i; diff --git a/src/gc.c b/src/gc.c index ca97fe602..05e1b7aa2 100644 --- a/src/gc.c +++ b/src/gc.c @@ -162,6 +162,7 @@ struct _gc_pheader { #define GC_DUMP_MEM 2 #define GC_NO_THREADS 4 #define GC_FORCE_MAJOR 8 +#define GC_PROFILE_MEM 16 static int gc_flags = 0; static gc_pheader *gc_level1_null[1<stack.size * sizeof(void*); + } + int pages = gc_stats.pages_count; + gc_pheader *p = gc_free_pheaders; + while( p ) { + pages++; + p = p->next_page; + } + gc_mem += sizeof(gc_pheader) * pages; + gc_mem += sizeof(void*) * gc_roots_max; + gc_mem += (sizeof(void*) + sizeof(hl_thread_info)) * gc_threads.count; + for(i=0;i<(1<