mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: free up memory from caches owned by indexDB when it is deleted
This commit is contained in:
parent
33ea2120c3
commit
e8377011ab
1 changed files with 12 additions and 5 deletions
|
@ -111,17 +111,15 @@ func openIndexDB(path string, metricIDCache, metricNameCache *fastcache.Cache, c
|
||||||
|
|
||||||
// Do not persist tagCache in files, since it is very volatile.
|
// Do not persist tagCache in files, since it is very volatile.
|
||||||
mem := memory.Allowed()
|
mem := memory.Allowed()
|
||||||
tagCache := fastcache.New(mem / 32)
|
|
||||||
|
|
||||||
db := &indexDB{
|
db := &indexDB{
|
||||||
refCount: 1,
|
refCount: 1,
|
||||||
tb: tb,
|
tb: tb,
|
||||||
name: name,
|
name: name,
|
||||||
|
|
||||||
tagCache: tagCache,
|
tagCache: fastcache.New(mem / 32),
|
||||||
metricIDCache: metricIDCache,
|
metricIDCache: metricIDCache,
|
||||||
metricNameCache: metricNameCache,
|
metricNameCache: metricNameCache,
|
||||||
|
|
||||||
uselessTagFiltersCache: fastcache.New(mem / 128),
|
uselessTagFiltersCache: fastcache.New(mem / 128),
|
||||||
|
|
||||||
currHourMetricIDs: currHourMetricIDs,
|
currHourMetricIDs: currHourMetricIDs,
|
||||||
|
@ -261,6 +259,15 @@ func (db *indexDB) decRef() {
|
||||||
db.tb.MustClose()
|
db.tb.MustClose()
|
||||||
db.SetExtDB(nil)
|
db.SetExtDB(nil)
|
||||||
|
|
||||||
|
// Free space occupied by caches owned by db.
|
||||||
|
db.tagCache.Reset()
|
||||||
|
db.uselessTagFiltersCache.Reset()
|
||||||
|
|
||||||
|
db.tagCache = nil
|
||||||
|
db.metricIDCache = nil
|
||||||
|
db.metricNameCache = nil
|
||||||
|
db.uselessTagFiltersCache = nil
|
||||||
|
|
||||||
if atomic.LoadUint64(&db.mustDrop) == 0 {
|
if atomic.LoadUint64(&db.mustDrop) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue