mem: Add cache class destructor to avoid memory leaks

Make valgrind a little bit happier
This commit is contained in:
Xiangyu Dong
2013-07-18 08:29:47 -04:00
parent 3ede4dceb8
commit 4e8ecd7c6f
2 changed files with 13 additions and 0 deletions

View File

@@ -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

View File

@@ -83,6 +83,16 @@ Cache<TagStore>::Cache(const Params *p)
prefetcher->setCache(this);
}
template<class TagStore>
Cache<TagStore>::~Cache()
{
delete [] tempBlock->data;
delete tempBlock;
delete cpuSidePort;
delete memSidePort;
}
template<class TagStore>
void
Cache<TagStore>::regStats()