aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/mem_pool.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-12-12 19:50:20 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-12-12 19:50:20 +0000
commit3617535f341e5ea4df04b94e10f78c1f9ee5e814 (patch)
tree0aa335361422b1ee63e74dea325ca1279e960bbd /src/libutil/mem_pool.c
parenteba3b1535d33c93949d0d53234ffb373772de1a5 (diff)
downloadrspamd-3617535f341e5ea4df04b94e10f78c1f9ee5e814.tar.gz
rspamd-3617535f341e5ea4df04b94e10f78c1f9ee5e814.zip
[Minor] Track memory usage in mempool
Diffstat (limited to 'src/libutil/mem_pool.c')
-rw-r--r--src/libutil/mem_pool.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libutil/mem_pool.c b/src/libutil/mem_pool.c
index c01ce0c2c..ed3a6b73d 100644
--- a/src/libutil/mem_pool.c
+++ b/src/libutil/mem_pool.c
@@ -393,6 +393,8 @@ memory_pool_alloc_common (rspamd_mempool_t * pool, gsize size,
if (pool) {
POOL_MTX_LOCK ();
+ pool->used_memory += size;
+
if (always_malloc && pool_type != RSPAMD_MEMPOOL_SHARED) {
void *ptr;
@@ -416,6 +418,10 @@ memory_pool_alloc_common (rspamd_mempool_t * pool, gsize size,
}
if (cur == NULL || free < size) {
+ if (free < size) {
+ pool->wasted_memory += free;
+ }
+
/* Allocate new chain element */
if (pool->elt_len >= size + MIN_MEM_ALIGNMENT) {
pool->entry->elts[pool->entry->cur_elts].fragmentation += size;