From: Martin Quinson Date: Fri, 2 Feb 2018 21:52:51 +0000 (+0100) Subject: try to plug a memleak X-Git-Tag: v3.19~277 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d53a2108a1ea38b2f952abb48c39730ccc91c2a8 try to plug a memleak --- diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index 670f5022c9..147f538aa3 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -165,6 +165,8 @@ public: /** Signal to others that a new actor has been created **/ static simgrid::xbt::signal onCreation; + /** Signal indicating that the given actor is about to disappear */ + static simgrid::xbt::signal onDestruction; /** Create an actor using a function * diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index 5e07894d8d..a81f54a2e7 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -22,6 +22,7 @@ namespace simgrid { namespace s4u { simgrid::xbt::signal s4u::Actor::onCreation; +simgrid::xbt::signal s4u::Actor::onDestruction; // ***** Actor creation ***** ActorPtr Actor::self() diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index 935ca1b12b..5d347f1199 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -462,6 +462,7 @@ void SIMIX_process_kill(smx_actor_t process, smx_actor_t issuer) { return; } + simgrid::s4u::Actor::onDestruction(process->iface()); XBT_DEBUG("Killing process %s@%s", process->getCname(), process->host->getCname()); process->context->iwannadie = 1; diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index a161b19b74..5aade555a7 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -628,6 +628,11 @@ void SMPI_init(){ simgrid::s4u::Actor::onCreation.connect([](simgrid::s4u::ActorPtr actor) { smpi_add_process(actor); }); + simgrid::s4u::Actor::onDestruction.connect([](simgrid::s4u::ActorPtr actor) { + delete process_data.at(actor); + process_data.erase(actor); + }); + smpi_init_options(); smpi_global_init(); smpi_check_options();