Memory optimization (removing scheduled events instead of just cancelling them)
diff --git a/apps/ndn-consumer.cc b/apps/ndn-consumer.cc
index 2c13925..98febd7 100644
--- a/apps/ndn-consumer.cc
+++ b/apps/ndn-consumer.cc
@@ -114,7 +114,10 @@
{
m_retxTimer = retxTimer;
if (m_retxEvent.IsRunning ())
- m_retxEvent.Cancel (); // cancel any scheduled cleanup events
+ {
+ // m_retxEvent.Cancel (); // cancel any scheduled cleanup events
+ Simulator::Remove (m_retxEvent); // slower, but better for memory
+ }
// schedule even with new timeout
m_retxEvent = Simulator::Schedule (m_retxTimer,
diff --git a/model/pit/ndn-pit-impl.cc b/model/pit/ndn-pit-impl.cc
index bb8e42a..da3f4f3 100644
--- a/model/pit/ndn-pit-impl.cc
+++ b/model/pit/ndn-pit-impl.cc
@@ -170,8 +170,9 @@
template<class Policy>
void
PitImpl<Policy>::RescheduleCleaning ()
-{
- m_cleanEvent.Cancel ();
+{
+ // m_cleanEvent.Cancel ();
+ Simulator::Remove (m_cleanEvent); // slower, but better for memory
if (i_time.empty ())
{
// NS_LOG_DEBUG ("No items in PIT");