diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2018-08-08 16:44:43 +0200 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2018-08-08 20:17:55 +0200 |
commit | 602a6584ee4f7c9f881204cc413fab73f18791f0 (patch) | |
tree | 77ff31767a676b1f544b1938065995c285c78ce2 /lib/memory_vty.c | |
parent | build: rework mallinfo test & find malloc_size (diff) | |
download | frr-602a6584ee4f7c9f881204cc413fab73f18791f0.tar.xz frr-602a6584ee4f7c9f881204cc413fab73f18791f0.zip |
lib: count total memory allocation per MTYPE
If malloc_usable_size() or malloc_size() are available, we can count
total usage of a particular MTYPE. (Without the functions, we don't
know how much to subtract on free.)
Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib/memory_vty.c')
-rw-r--r-- | lib/memory_vty.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/memory_vty.c b/lib/memory_vty.c index 388273128..9ee2e52ec 100644 --- a/lib/memory_vty.c +++ b/lib/memory_vty.c @@ -79,12 +79,21 @@ static int qmem_walker(void *arg, struct memgroup *mg, struct memtype *mt) if (mt->n_alloc != 0) { char size[32]; snprintf(size, sizeof(size), "%6zu", mt->size); - vty_out(vty, "%-30s: %10zu %s\n", mt->name, + +#ifdef HAVE_MALLOC_USABLE_SIZE +#define TSTR " %9zu" +#define TARG , mt->total +#else +#define TSTR "" +#define TARG +#endif + vty_out(vty, "%-30s: %10zu %-16s"TSTR"\n", mt->name, mt->n_alloc, mt->size == 0 ? "" : mt->size == SIZE_VAR ? "(variably sized)" - : size); + : size + TARG); } } return 0; |