diff options
author | Vladimir Kobal <vlad@prokk.net> | 2022-04-01 15:22:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-01 15:22:49 +0200 |
commit | 7bfc543172115ee8c042f605c3af1432c43d1b07 (patch) | |
tree | ee0bce08b5526aae8dc13f737eddfe7696f26a61 /database | |
parent | 6ba6d670172ab4387ff722348f61c8268c410ed6 (diff) |
Fix memory leaks on Netdata exit (#12511)
* Fix memory leaks in dimensions and charts
* Initialize superblock memory regions
* Clean up static threads
* Fix memory leaks in compression
* Fix memory leaks in rrdcaltemplate
* Fix memory leaks in health config
* Fix ACLK memory leaks
Diffstat (limited to 'database')
-rw-r--r-- | database/engine/datafile.c | 1 | ||||
-rw-r--r-- | database/engine/journalfile.c | 1 | ||||
-rw-r--r-- | database/rrdcalctemplate.c | 3 | ||||
-rw-r--r-- | database/rrddim.c | 2 | ||||
-rw-r--r-- | database/rrdset.c | 7 |
5 files changed, 14 insertions, 0 deletions
diff --git a/database/engine/datafile.c b/database/engine/datafile.c index d423110790..46d7a8f101 100644 --- a/database/engine/datafile.c +++ b/database/engine/datafile.c @@ -159,6 +159,7 @@ int create_data_file(struct rrdengine_datafile *datafile) if (unlikely(ret)) { fatal("posix_memalign:%s", strerror(ret)); } + memset(superblock, 0, sizeof(*superblock)); (void) strncpy(superblock->magic_number, RRDENG_DF_MAGIC, RRDENG_MAGIC_SZ); (void) strncpy(superblock->version, RRDENG_DF_VER, RRDENG_VER_SZ); superblock->tier = 1; diff --git a/database/engine/journalfile.c b/database/engine/journalfile.c index ad5f7befc7..1541eb10aa 100644 --- a/database/engine/journalfile.c +++ b/database/engine/journalfile.c @@ -210,6 +210,7 @@ int create_journal_file(struct rrdengine_journalfile *journalfile, struct rrdeng if (unlikely(ret)) { fatal("posix_memalign:%s", strerror(ret)); } + memset(superblock, 0, sizeof(*superblock)); (void) strncpy(superblock->magic_number, RRDENG_JF_MAGIC, RRDENG_MAGIC_SZ); (void) strncpy(superblock->version, RRDENG_JF_VER, RRDENG_VER_SZ); diff --git a/database/rrdcalctemplate.c b/database/rrdcalctemplate.c index 67288e9dbb..9789f4beab 100644 --- a/database/rrdcalctemplate.c +++ b/database/rrdcalctemplate.c @@ -120,6 +120,9 @@ inline void rrdcalctemplate_free(RRDCALCTEMPLATE *rt) { freez(rt->name); freez(rt->exec); freez(rt->recipient); + freez(rt->classification); + freez(rt->component); + freez(rt->type); freez(rt->context); freez(rt->source); freez(rt->units); diff --git a/database/rrddim.c b/database/rrddim.c index f0514180df..df45363bc7 100644 --- a/database/rrddim.c +++ b/database/rrddim.c @@ -495,6 +495,7 @@ void rrddim_free_custom(RRDSET *st, RRDDIM *rd, int db_rotated) case RRD_MEMORY_MODE_RAM: debug(D_RRD_CALLS, "Unmapping dimension '%s'.", rd->name); freez((void *)rd->id); + freez((void *)rd->name); freez(rd->cache_filename); freez(rd->state); munmap(rd, rd->memsize); @@ -505,6 +506,7 @@ void rrddim_free_custom(RRDSET *st, RRDDIM *rd, int db_rotated) case RRD_MEMORY_MODE_DBENGINE: debug(D_RRD_CALLS, "Removing dimension '%s'.", rd->name); freez((void *)rd->id); + freez((void *)rd->name); freez(rd->cache_filename); freez(rd->state); freez(rd); diff --git a/database/rrdset.c b/database/rrdset.c index 7b58d3780d..7a1ce74e1d 100644 --- a/database/rrdset.c +++ b/database/rrdset.c @@ -395,6 +395,13 @@ void rrdset_free(RRDSET *st) { netdata_rwlock_destroy(&st->state->labels.labels_rwlock); // free directly allocated members + freez((void *)st->name); + freez(st->type); + freez(st->family); + freez(st->title); + freez(st->units); + freez(st->context); + freez(st->cache_dir); freez(st->config_section); freez(st->plugin_name); freez(st->module_name); |