From 08deb6d4bf648a9bbe311b03b2578c33c13d2626 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" <114750+alfredh@users.noreply.github.com> Date: Sat, 21 Dec 2024 14:39:20 +0100 Subject: [PATCH] mem: remove peak from memstat --- include/re_mem.h | 2 -- src/mem/mem.c | 10 +--------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/include/re_mem.h b/include/re_mem.h index bf259a191..70b135df5 100644 --- a/include/re_mem.h +++ b/include/re_mem.h @@ -16,9 +16,7 @@ typedef void (mem_destroy_h)(void *data); /** Memory Statistics */ struct memstat { size_t bytes_cur; /**< Current bytes allocated */ - size_t bytes_peak; /**< Peak bytes allocated */ size_t blocks_cur; /**< Current blocks allocated */ - size_t blocks_peak; /**< Peak blocks allocated */ }; void *mem_alloc(size_t size, mem_destroy_h *dh); diff --git a/src/mem/mem.c b/src/mem/mem.c index 0bf908bab..0d5a7c907 100644 --- a/src/mem/mem.c +++ b/src/mem/mem.c @@ -45,7 +45,7 @@ static const size_t mem_magic = 0xe7fb9ac4; static ssize_t threshold = -1; /**< Memory threshold, disabled by default */ static struct memstat memstat = { - 0,0,0,0 + 0,0 }; static once_flag flag = ONCE_FLAG_INIT; @@ -72,9 +72,7 @@ static inline void mem_unlock(void) #define STAT_ALLOC(_m, _size) \ mem_lock(); \ memstat.bytes_cur += (_size); \ - memstat.bytes_peak = max(memstat.bytes_cur, memstat.bytes_peak); \ ++memstat.blocks_cur; \ - memstat.blocks_peak = max(memstat.blocks_cur, memstat.blocks_peak); \ mem_unlock(); \ (_m)->size = (uint32_t)(_size); \ (_m)->magic = mem_magic; @@ -83,7 +81,6 @@ static inline void mem_unlock(void) #define STAT_REALLOC(_m, _size) \ mem_lock(); \ memstat.bytes_cur += ((_size) - (_m)->size); \ - memstat.bytes_peak = max(memstat.bytes_cur, memstat.bytes_peak); \ mem_unlock(); \ (_m)->size = (uint32_t)(_size) @@ -533,11 +530,6 @@ int mem_status(struct re_printf *pf, void *unused) stat.blocks_cur, stat.bytes_cur, stat.bytes_cur + (stat.blocks_cur * (size_t)mem_header_size)); - err |= re_hprintf(pf, - " Peak: %zu blocks, %zu bytes (total %zu bytes)\n", - stat.blocks_peak, stat.bytes_peak, - stat.bytes_peak - + (stat.blocks_peak * (size_t)mem_header_size)); err |= re_hprintf(pf, " Total %u blocks allocated\n", c); return err;