From: Daniel R. Carvalho Date: Fri, 23 Feb 2018 14:55:06 +0000 (+0100) Subject: mem-cache: Fix CacheSet memory leak X-Git-Tag: v19.0.0.0~2274 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fbe63074e3a8128bdbe1a5e8f6509c565a3abbd4;p=gem5.git mem-cache: Fix CacheSet memory leak 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 Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris --- diff --git a/src/mem/cache/tags/base_set_assoc.cc b/src/mem/cache/tags/base_set_assoc.cc index cf647ac4d..c39822929 100644 --- a/src/mem/cache/tags/base_set_assoc.cc +++ b/src/mem/cache/tags/base_set_assoc.cc @@ -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) { diff --git a/src/mem/cache/tags/cacheset.hh b/src/mem/cache/tags/cacheset.hh index 69109d10c..5a3445659 100644 --- a/src/mem/cache/tags/cacheset.hh +++ b/src/mem/cache/tags/cacheset.hh @@ -61,7 +61,7 @@ class CacheSet int assoc; /** Cache blocks in this set, maintained in LRU order 0 = MRU. */ - Blktype **blks; + std::vector blks; /** * Find a block matching the tag in this set.