Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mem: remove peak from memstat #1238

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading