mem-cache: Fix CacheSet memory leak
authorDaniel R. Carvalho <odanrc@yahoo.com.br>
Fri, 23 Feb 2018 14:55:06 +0000 (15:55 +0100)
committerDaniel Carvalho <odanrc@yahoo.com.br>
Sat, 24 Feb 2018 15:54:57 +0000 (15:54 +0000)
CacheSet blocks were being allocated but never freed.
Used vector to avoid using pure C array.

Change-Id: I6f32fa5a305ff4e1d7602535026c1396764102ed
Reviewed-on: https://gem5-review.googlesource.com/8603
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>

src/mem/cache/tags/base_set_assoc.cc
src/mem/cache/tags/cacheset.hh

index cf647ac4d79efbb0ae6cfced83a0c03290aab20f..c39822929c42182c15c44dae7c13a489fec2765a 100644 (file)
@@ -84,7 +84,7 @@ BaseSetAssoc::BaseSetAssoc(const Params *p)
     for (unsigned i = 0; i < numSets; ++i) {
         sets[i].assoc = assoc;
 
-        sets[i].blks = new BlkType*[assoc];
+        sets[i].blks.resize(assoc);
 
         // link in the data blocks
         for (unsigned j = 0; j < assoc; ++j) {
index 69109d10c78a31f87eb0006a50596c6220774afe..5a3445659f8d2f52080854505dbdded6e3d4f5ec 100644 (file)
@@ -61,7 +61,7 @@ class CacheSet
     int assoc;
 
     /** Cache blocks in this set, maintained in LRU order 0 = MRU. */
-    Blktype **blks;
+    std::vector<Blktype*> blks;
 
     /**
      * Find a block matching the tag in this set.