Solved memory leak on terminate job ctor

This commit is contained in:
Benjamin Bouvier 2012-07-18 14:02:39 +02:00
commit 766a8f40d6
2 changed files with 14 additions and 11 deletions

View file

@ -552,24 +552,25 @@ namespace eo
Job( AssignmentAlgorithm& _algo, Job( AssignmentAlgorithm& _algo,
int _masterRank, int _masterRank,
int _workerStopCondition, int _workerStopCondition,
JobStore<JobData> & store JobStore<JobData> & _store
) : ) :
assignmentAlgo( _algo ), assignmentAlgo( _algo ),
masterRank( _masterRank ), masterRank( _masterRank ),
workerStopCondition( _workerStopCondition ), workerStopCondition( _workerStopCondition ),
comm( Node::comm() ), comm( Node::comm() ),
// Functors // Functors
sendTask( store.sendTask() ), store( _store ),
handleResponse( store.handleResponse() ), sendTask( _store.sendTask() ),
processTask( store.processTask() ), handleResponse( _store.handleResponse() ),
isFinished( store.isFinished() ) processTask( _store.processTask() ),
isFinished( _store.isFinished() )
{ {
_isMaster = Node::comm().rank() == _masterRank; _isMaster = Node::comm().rank() == _masterRank;
sendTask.data( store.data() ); sendTask.data( _store.data() );
handleResponse.data( store.data() ); handleResponse.data( _store.data() );
processTask.data( store.data() ); processTask.data( _store.data() );
isFinished.data( store.data() ); isFinished.data( _store.data() );
} }
protected: protected:
@ -764,6 +765,7 @@ namespace eo
const int workerStopCondition; const int workerStopCondition;
bmpi::communicator& comm; bmpi::communicator& comm;
JobStore<JobData>& store;
SendTaskFunction<JobData> & sendTask; SendTaskFunction<JobData> & sendTask;
HandleResponseFunction<JobData> & handleResponse; HandleResponseFunction<JobData> & handleResponse;
ProcessTaskFunction<JobData> & processTask; ProcessTaskFunction<JobData> & processTask;

View file

@ -115,7 +115,7 @@ namespace eo
*/ */
EmptyJob( AssignmentAlgorithm& algo, int masterRank ) : EmptyJob( AssignmentAlgorithm& algo, int masterRank ) :
OneShotJob<void>( algo, masterRank, *(new DummyJobStore) ) OneShotJob<void>( algo, masterRank, *(new DummyJobStore) )
// FIXME memory leak, meaningless but present // the job store is deleted on destructor
{ {
// empty // empty
} }
@ -127,6 +127,7 @@ namespace eo
{ {
comm.send( idles[i], Channel::Commands, Message::Kill ); comm.send( idles[i], Channel::Commands, Message::Kill );
} }
delete & this->store;
} }
}; };