Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make this example valgrind-clean
[simgrid.git] / examples / cpp / dag-scheduling / s4u-dag-scheduling.cpp
index 3feed78..ff68f38 100644 (file)
@@ -95,6 +95,7 @@ static void schedule_on(sg4::ExecPtr exec, sg4::Host* host, double busy_until =
 {
   exec->set_host(host);
   // We use the user data field to store up to when the host is busy
+  delete host->get_data<double>(); // In case we're erasing a previous value
   host->set_data(new double(busy_until));
   // we can also set the destination of all the input comms of this exec
   for (const auto& pred : exec->get_dependencies()) {
@@ -191,6 +192,10 @@ int main(int argc, char** argv)
     e.run();
   }
 
+  /* Cleanup memory */
+  for (auto const& host : e.get_all_hosts())
+    delete host->get_data<double>();
+
   XBT_INFO("Simulation Time: %f", simgrid_get_clock());
 
   return 0;