diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2012-07-09 12:35:30 -0400 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2012-07-09 12:35:30 -0400 |
commit | ff5718f042ecccee694ae79c9386a589fd77e8ef (patch) | |
tree | 2caecba4b46e01b1dc964b62eac700219b6aa382 /src/cpu | |
parent | 92eaac07118a620c2c9dd48921eefcb7ca4422a8 (diff) | |
download | gem5-ff5718f042ecccee694ae79c9386a589fd77e8ef.tar.xz |
Fix: Address a few benign memory leaks
This patch is the result of static analysis identifying a number of
memory leaks. The leaks are all benign as they are a result of not
deallocating memory in the desctructor. The fix still has value as it
removes false positives in the static analysis.
Diffstat (limited to 'src/cpu')
-rw-r--r-- | src/cpu/activity.cc | 5 | ||||
-rw-r--r-- | src/cpu/activity.hh | 1 | ||||
-rw-r--r-- | src/cpu/base.cc | 3 | ||||
-rw-r--r-- | src/cpu/o3/regfile.hh | 12 |
4 files changed, 21 insertions, 0 deletions
diff --git a/src/cpu/activity.cc b/src/cpu/activity.cc index 13613cffc..87875c683 100644 --- a/src/cpu/activity.cc +++ b/src/cpu/activity.cc @@ -46,6 +46,11 @@ ActivityRecorder::ActivityRecorder(const string &name, int num_stages, std::memset(stageActive, 0, numStages); } +ActivityRecorder::~ActivityRecorder() +{ + delete[] stageActive; +} + void ActivityRecorder::activity() { diff --git a/src/cpu/activity.hh b/src/cpu/activity.hh index f119c95cc..7913bf5e7 100644 --- a/src/cpu/activity.hh +++ b/src/cpu/activity.hh @@ -54,6 +54,7 @@ class ActivityRecorder public: ActivityRecorder(const std::string &name, int num_stages, int longest_latency, int count); + ~ActivityRecorder(); /** Records that there is activity this cycle. */ void activity(); diff --git a/src/cpu/base.cc b/src/cpu/base.cc index c942cad44..4017140a5 100644 --- a/src/cpu/base.cc +++ b/src/cpu/base.cc @@ -243,6 +243,9 @@ BaseCPU::enableFunctionTrace() BaseCPU::~BaseCPU() { + delete profileEvent; + delete[] comLoadEventQueue; + delete[] comInstEventQueue; } void diff --git a/src/cpu/o3/regfile.hh b/src/cpu/o3/regfile.hh index 117c955c2..d0f50c85c 100644 --- a/src/cpu/o3/regfile.hh +++ b/src/cpu/o3/regfile.hh @@ -75,6 +75,11 @@ class PhysRegFile PhysRegFile(O3CPU *_cpu, unsigned _numPhysicalIntRegs, unsigned _numPhysicalFloatRegs); + /** + * Destructor to free resources + */ + ~PhysRegFile(); + //Everything below should be pretty well identical to the normal //register file that exists within AlphaISA class. //The duplication is unfortunate but it's better than having @@ -197,4 +202,11 @@ PhysRegFile<Impl>::PhysRegFile(O3CPU *_cpu, unsigned _numPhysicalIntRegs, memset(floatRegFile, 0, sizeof(PhysFloatReg) * numPhysicalFloatRegs); } +template <class Impl> +PhysRegFile<Impl>::~PhysRegFile() +{ + delete intRegFile; + delete floatRegFile; +} + #endif |