Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[examples] smpi-replay-mmd: (ugly) memory clean-up
authorMillian Poquet <millian.poquet@inria.fr>
Mon, 22 Oct 2018 13:51:20 +0000 (15:51 +0200)
committerMillian Poquet <millian.poquet@inria.fr>
Mon, 22 Oct 2018 13:51:20 +0000 (15:51 +0200)
examples/smpi/replay_multiple_manual_deploy/replay_multiple_manual.cpp

index 59aeb70..ae6b7f6 100644 (file)
@@ -65,12 +65,22 @@ static void smpi_replay_process(Job* job, simgrid::s4u::BarrierPtr barrier, int
   argv[3]     = xbt_strdup(job->traces_filenames[rank].c_str()); // smpi trace file for this rank
   argv[4]     = xbt_strdup("0");                                 // ?
 
+  // Ugly double storage used for memory deallocation, as SMPI changes argc/argv without cleaning memory.
+  char* to_free[2] = {argv[0], argv[1]}; // <-- This ugly array should disappear.
+
   XBT_INFO("Replaying rank %d of job %d (smpi_app '%s')", rank, job->unique_job_number, job->smpi_app_name.c_str());
   smpi_replay_run(&argc, &argv);
   XBT_INFO("Finished replaying rank %d of job %d (smpi_app '%s')", rank, job->unique_job_number,
            job->smpi_app_name.c_str());
 
   barrier->wait();
+
+  // Memory clean-up
+  for (int i = 0; i < 2; ++i) // <-- This ugly loop should disappear.
+    xbt_free(to_free[i]);
+  for (int i = 0; i < argc; ++i)
+    xbt_free(argv[i]);
+  xbt_free(argv);
 }
 
 // Sleeps for a given amount of time