From: Xiangyu Dong Date: Thu, 18 Jul 2013 12:29:47 +0000 (-0400) Subject: mem: Add cache class destructor to avoid memory leaks X-Git-Tag: stable_2014_02_15~190 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4e8ecd7c6fd0447f563179b5a8fdbb13b562ca9e;p=gem5.git mem: Add cache class destructor to avoid memory leaks Make valgrind a little bit happier --- diff --git a/src/mem/cache/cache.hh b/src/mem/cache/cache.hh index faa317917..729e1f32c 100644 --- a/src/mem/cache/cache.hh +++ b/src/mem/cache/cache.hh @@ -411,6 +411,9 @@ class Cache : public BaseCache /** Instantiates a basic cache object. */ Cache(const Params *p); + /** Non-default destructor is needed to deallocate memory. */ + virtual ~Cache(); + void regStats(); /** serialize the state of the caches diff --git a/src/mem/cache/cache_impl.hh b/src/mem/cache/cache_impl.hh index 90020c295..b4ace5f6c 100644 --- a/src/mem/cache/cache_impl.hh +++ b/src/mem/cache/cache_impl.hh @@ -83,6 +83,16 @@ Cache::Cache(const Params *p) prefetcher->setCache(this); } +template +Cache::~Cache() +{ + delete [] tempBlock->data; + delete tempBlock; + + delete cpuSidePort; + delete memSidePort; +} + template void Cache::regStats()