Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a destructor to the NetworkNS3Model to cleanup the ns-3 side
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 28 Jan 2022 22:03:45 +0000 (23:03 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 28 Jan 2022 22:13:12 +0000 (23:13 +0100)
Even if in my tests, calling Simulator::Destroy as indicated by the
ns-3 doc does not actually fix our leakage.

src/surf/network_ns3.cpp
src/surf/network_ns3.hpp

index a1b8946..f0708f3 100644 (file)
@@ -346,6 +346,11 @@ NetworkNS3Model::NetworkNS3Model(const std::string& name) : NetworkModel(name)
   s4u::NetZone::on_seal_cb(&zoneCreation_cb);
 }
 
+NetworkNS3Model::~NetworkNS3Model()
+{
+  ns3::Simulator::Destroy();
+}
+
 StandardLinkImpl* NetworkNS3Model::create_link(const std::string& name, const std::vector<double>& bandwidths)
 {
   xbt_assert(bandwidths.size() == 1, "ns-3 links must use only 1 bandwidth.");
index 857ee4c..09f681f 100644 (file)
@@ -17,6 +17,7 @@ namespace resource {
 class NetworkNS3Model : public NetworkModel {
 public:
   explicit NetworkNS3Model(const std::string& name);
+  ~NetworkNS3Model();
   StandardLinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidth) override;
   StandardLinkImpl* create_wifi_link(const std::string& name, const std::vector<double>& bandwidth) override;
   Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;