From 766a8f40d6a416f7016f22633daa03ed5481ace9 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Wed, 18 Jul 2012 14:02:39 +0200 Subject: [PATCH] Solved memory leak on terminate job ctor --- eo/src/mpi/eoMpi.h | 22 ++++++++++++---------- eo/src/mpi/eoTerminateJob.h | 3 ++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/eo/src/mpi/eoMpi.h b/eo/src/mpi/eoMpi.h index cf5cbeb5..abb5fa6f 100644 --- a/eo/src/mpi/eoMpi.h +++ b/eo/src/mpi/eoMpi.h @@ -539,7 +539,7 @@ namespace eo * AssignmentAlgorithm for more details. * * @param _masterRank The MPI rank of the master. - * + * * @param _workerStopCondition Number of the message which will cause the workers to terminate. It could * be one of the constants defined in eo::mpi::Commands, or any other integer. The user has to be sure * that a message containing this integer will be sent to each worker on the Commands channel, otherwise @@ -552,24 +552,25 @@ namespace eo Job( AssignmentAlgorithm& _algo, int _masterRank, int _workerStopCondition, - JobStore & store + JobStore & _store ) : assignmentAlgo( _algo ), masterRank( _masterRank ), workerStopCondition( _workerStopCondition ), comm( Node::comm() ), // Functors - sendTask( store.sendTask() ), - handleResponse( store.handleResponse() ), - processTask( store.processTask() ), - isFinished( store.isFinished() ) + store( _store ), + sendTask( _store.sendTask() ), + handleResponse( _store.handleResponse() ), + processTask( _store.processTask() ), + isFinished( _store.isFinished() ) { _isMaster = Node::comm().rank() == _masterRank; - sendTask.data( store.data() ); - handleResponse.data( store.data() ); - processTask.data( store.data() ); - isFinished.data( store.data() ); + sendTask.data( _store.data() ); + handleResponse.data( _store.data() ); + processTask.data( _store.data() ); + isFinished.data( _store.data() ); } protected: @@ -764,6 +765,7 @@ namespace eo const int workerStopCondition; bmpi::communicator& comm; + JobStore& store; SendTaskFunction & sendTask; HandleResponseFunction & handleResponse; ProcessTaskFunction & processTask; diff --git a/eo/src/mpi/eoTerminateJob.h b/eo/src/mpi/eoTerminateJob.h index e0b4a5bd..fe231f0e 100644 --- a/eo/src/mpi/eoTerminateJob.h +++ b/eo/src/mpi/eoTerminateJob.h @@ -115,7 +115,7 @@ namespace eo */ EmptyJob( AssignmentAlgorithm& algo, int masterRank ) : OneShotJob( algo, masterRank, *(new DummyJobStore) ) - // FIXME memory leak, meaningless but present + // the job store is deleted on destructor { // empty } @@ -127,6 +127,7 @@ namespace eo { comm.send( idles[i], Channel::Commands, Message::Kill ); } + delete & this->store; } };