Skip to content

Commit

Permalink
mem: remove peak from memstat
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredh authored and sreimers committed Dec 26, 2024
1 parent ef7674e commit 08deb6d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
2 changes: 0 additions & 2 deletions include/re_mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 1 addition & 9 deletions src/mem/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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)

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 08deb6d

Please sign in to comment.