Jui-min Lee has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/57329 )
Change subject: systemc: Fix memory leak of sc_event_list
......................................................................
systemc: Fix memory leak of sc_event_list
Make SensitivityAnd/OrList class track the sc_event_and/or_list and
delete it when the Sensitivity object itself is deleted.
Bug: 222177290
Test: Run gem5 unittests and our presubmits
Change-Id: Ib46f8dfb6727f77ad843ba33ce22c7e6d2645ff2
---
M src/systemc/core/sensitivity.cc
M src/systemc/core/sensitivity.hh
2 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/src/systemc/core/sensitivity.cc
b/src/systemc/core/sensitivity.cc
index 8c4aa23..1367b29 100644
--- a/src/systemc/core/sensitivity.cc
+++ b/src/systemc/core/sensitivity.cc
@@ -214,9 +214,21 @@
DynamicSensitivityEventOrList::DynamicSensitivityEventOrList(
Process *p, const sc_core::sc_event_or_list *eol) :
- Sensitivity(p), DynamicSensitivity(p), SensitivityEvents(p,
eol->events)
+ Sensitivity(p),
+ DynamicSensitivity(p),
+ SensitivityEvents(p, eol->events),
+ list(eol)
{}
+DynamicSensitivityEventOrList::~DynamicSensitivityEventOrList()
+{
+ if (list->autoDelete) {
+ panic_if(list->busy,
+ "sc_event_or_list can never be busy in gem5
implementation");
+ delete list;
+ }
+}
+
bool
DynamicSensitivityEventOrList::notifyWork(Event *e)
{
@@ -233,9 +245,21 @@
DynamicSensitivityEventAndList::DynamicSensitivityEventAndList(
Process *p, const sc_core::sc_event_and_list *eal) :
- Sensitivity(p), DynamicSensitivity(p), SensitivityEvents(p,
eal->events)
+ Sensitivity(p),
+ DynamicSensitivity(p),
+ SensitivityEvents(p, eal->events),
+ list(eal)
{}
+DynamicSensitivityEventAndList::~DynamicSensitivityEventAndList()
+{
+ if (list->autoDelete) {
+ panic_if(list->busy,
+ "sc_event_and_list can never be busy in gem5
implementation");
+ delete list;
+ }
+}
+
bool
DynamicSensitivityEventAndList::notifyWork(Event *e)
{
diff --git a/src/systemc/core/sensitivity.hh
b/src/systemc/core/sensitivity.hh
index 9e76969..af4ce2d 100644
--- a/src/systemc/core/sensitivity.hh
+++ b/src/systemc/core/sensitivity.hh
@@ -274,8 +274,11 @@
DynamicSensitivityEventOrList(
Process *p, const sc_core::sc_event_or_list *eol);
+ ~DynamicSensitivityEventOrList();
bool notifyWork(Event *e) override;
+
+ const sc_core::sc_event_or_list *list;
};
//XXX This sensitivity can't be reused. To reset it, it has to be deleted
and
@@ -290,8 +293,11 @@
DynamicSensitivityEventAndList(
Process *p, const sc_core::sc_event_and_list *eal);
+ ~DynamicSensitivityEventAndList();
bool notifyWork(Event *e) override;
+
+ const sc_core::sc_event_and_list *list;
};
} // namespace sc_gem5
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/57329
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ib46f8dfb6727f77ad843ba33ce22c7e6d2645ff2
Gerrit-Change-Number: 57329
Gerrit-PatchSet: 1
Gerrit-Owner: Jui-min Lee <f...@google.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s