diff --git a/lib/storage/index_db.go b/lib/storage/index_db.go
index 3517346c5b..32975b9a94 100644
--- a/lib/storage/index_db.go
+++ b/lib/storage/index_db.go
@@ -60,13 +60,13 @@ type indexDB struct {
 	// Cache for fast MetricID -> MetricName lookup.
 	metricNameCache *fastcache.Cache
 
-	tagCachePrefixes     map[accountProjectKey]uint64
-	tagCachePrefixesLock sync.RWMutex
-
 	// Cache holding useless TagFilters entries, which have no tag filters
 	// matching low number of metrics.
 	uselessTagFiltersCache *fastcache.Cache
 
+	tagCachePrefixes     map[accountProjectKey]uint64
+	tagCachePrefixesLock sync.RWMutex
+
 	indexSearchPool sync.Pool
 
 	// An inmemory map[uint64]struct{} of deleted metricIDs.
@@ -120,21 +120,19 @@ func openIndexDB(path string, metricIDCache, metricNameCache *fastcache.Cache, c
 
 	// Do not persist tagCache in files, since it is very volatile.
 	mem := memory.Allowed()
-	tagCache := fastcache.New(mem / 32)
 
 	db := &indexDB{
 		refCount: 1,
 		tb:       tb,
 		name:     name,
 
-		tagCache:        tagCache,
-		metricIDCache:   metricIDCache,
-		metricNameCache: metricNameCache,
+		tagCache:               fastcache.New(mem / 32),
+		metricIDCache:          metricIDCache,
+		metricNameCache:        metricNameCache,
+		uselessTagFiltersCache: fastcache.New(mem / 128),
 
 		tagCachePrefixes: make(map[accountProjectKey]uint64),
 
-		uselessTagFiltersCache: fastcache.New(mem / 128),
-
 		currHourMetricIDs: currHourMetricIDs,
 		prevHourMetricIDs: prevHourMetricIDs,
 	}
@@ -272,6 +270,15 @@ func (db *indexDB) decRef() {
 	db.tb.MustClose()
 	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 {
 		return
 	}