summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiangyu Dong <rioshering@gmail.com>2013-07-18 08:29:47 -0400
committerXiangyu Dong <rioshering@gmail.com>2013-07-18 08:29:47 -0400
commit4e8ecd7c6fd0447f563179b5a8fdbb13b562ca9e (patch)
treea0ea852be2c10a1c182f3deae65edc243c87ac4e
parent3ede4dceb84fd4930ccb132659198741ae47730f (diff)
downloadgem5-4e8ecd7c6fd0447f563179b5a8fdbb13b562ca9e.tar.xz
mem: Add cache class destructor to avoid memory leaks
Make valgrind a little bit happier
-rw-r--r--src/mem/cache/cache.hh3
-rw-r--r--src/mem/cache/cache_impl.hh10
2 files changed, 13 insertions, 0 deletions
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
@@ -84,6 +84,16 @@ Cache<TagStore>::Cache(const Params *p)
}
template<class TagStore>
+Cache<TagStore>::~Cache()
+{
+ delete [] tempBlock->data;
+ delete tempBlock;
+
+ delete cpuSidePort;
+ delete memSidePort;
+}
+
+template<class TagStore>
void
Cache<TagStore>::regStats()
{