summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Sandberg <Andreas.Sandberg@ARM.com>2014-09-09 04:36:32 -0400
committerAndreas Sandberg <Andreas.Sandberg@ARM.com>2014-09-09 04:36:32 -0400
commit11494c4345e0de2b51dddcc936cedade76f8a90e (patch)
treea09f4fbe426871acea19d5171531f682dd06254a
parentda4539dc749c3d29c03de9b3130f1c9a7266be9d (diff)
downloadgem5-11494c4345e0de2b51dddcc936cedade76f8a90e.tar.xz
sim: Fix resource leak in BaseGlobalEvent
Static analysis revealed that BaseGlobalEvent::barrier was never deallocated. This changeset solves this leak by making the barrier allocation a part of the BaseGlobalEvent instead of storing a pointer to a separate heap-allocated barrier.
-rw-r--r--src/sim/global_event.cc4
-rw-r--r--src/sim/global_event.hh4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/sim/global_event.cc b/src/sim/global_event.cc
index fedee351f..f01df51d0 100644
--- a/src/sim/global_event.cc
+++ b/src/sim/global_event.cc
@@ -34,9 +34,9 @@
std::mutex BaseGlobalEvent::globalQMutex;
BaseGlobalEvent::BaseGlobalEvent(Priority p, Flags f)
+ : barrier(numMainEventQueues),
+ barrierEvent(numMainEventQueues, NULL)
{
- barrierEvent.resize(numMainEventQueues);
- barrier = new Barrier(numMainEventQueues);
}
diff --git a/src/sim/global_event.hh b/src/sim/global_event.hh
index 3a5297e78..88981b52a 100644
--- a/src/sim/global_event.hh
+++ b/src/sim/global_event.hh
@@ -100,7 +100,7 @@ class BaseGlobalEvent : public EventBase
// while waiting on the barrier to prevent deadlocks if
// another thread wants to lock the event queue.
EventQueue::ScopedRelease release(curEventQueue());
- return _globalEvent->barrier->wait();
+ return _globalEvent->barrier.wait();
}
public:
@@ -109,7 +109,7 @@ class BaseGlobalEvent : public EventBase
//! The barrier that all threads wait on before performing the
//! global event.
- Barrier *barrier;
+ Barrier barrier;
//! The individual local event instances (one per thread/event queue).
std::vector<BarrierEvent *> barrierEvent;