Skip to content

Commit

Permalink
dlmalloc: account the footprint of the initial heap
Browse files Browse the repository at this point in the history
While malloc_stats and friends are disabled and unused for wasi-libc,
it's neater to be consistent.

Background: My colleagues for some reasons enabled malloc_stats
and asked me why it reports negative values.

Note: Depending __heap_base, init_top() adjusts the address for
alignment. I think the amount of this adjustment is reported as
"used" by malloc_stats. I don't bother to "fix" it.
  • Loading branch information
yamt committed May 10, 2024
1 parent 2f088a9 commit bbe7fa6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dlmalloc/src/malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5250,6 +5250,8 @@ static void try_init_allocator(void) {
gm->least_addr = base;
gm->seg.base = base;
gm->seg.size = initial_heap_size;
gm->footprint = initial_heap_size;
gm->max_footprint = initial_heap_size;
gm->magic = mparams.magic;
gm->release_checks = MAX_RELEASE_CHECK_RATE;
init_bins(gm);
Expand Down

0 comments on commit bbe7fa6

Please sign in to comment.