Skip to content

Commit

Permalink
Memory leak removed because of alarm message
Browse files Browse the repository at this point in the history
  • Loading branch information
mesurajpandey committed Nov 28, 2017
1 parent 094fe71 commit 0a7e595
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion include/wrench/services/helpers/Alarm.h
Expand Up @@ -41,7 +41,7 @@ namespace wrench {

double date;
std::string reply_mailbox_name;
SimulationMessage* msg;
std::unique_ptr<SimulationMessage> msg;

int main() override;

Expand Down
8 changes: 2 additions & 6 deletions src/wrench/services/compute/batch/BatchService.cpp
Expand Up @@ -523,13 +523,13 @@ namespace wrench {
{{StandardJobExecutorProperty::THREAD_STARTUP_OVERHEAD,
this->getPropertyValueAsString(
BatchServiceProperty::THREAD_STARTUP_OVERHEAD)}});

std::unique_ptr<StandardJobExecutor> executor_uniq_ptr = std::unique_ptr<StandardJobExecutor>(executor);
this->running_standard_job_executors.insert(std::move(executor_uniq_ptr));
batch_job->setEndingTimeStamp(S4U_Simulation::getClock() + time_in_minutes * 60);

this->running_jobs.insert(std::move(batch_job_ptr));

// this->timeslots.push_back(batch_job->getEndingTimeStamp());
//remember the allocated resources for the job
batch_job->setAllocatedResources(resources);

Expand All @@ -540,8 +540,6 @@ namespace wrench {
std::unique_ptr<Alarm> alarm_ptr = std::unique_ptr<Alarm>(new Alarm(batch_job->getEndingTimeStamp(), this->hostname, this->mailbox_name, msg,
"batch_standard"));

// this->sent_alrm_msgs.push_back(msg);
//

standard_job_alarms.push_back(std::move(alarm_ptr));

Expand Down Expand Up @@ -576,7 +574,6 @@ namespace wrench {

// Put the job in the running queue
this->running_jobs.insert(std::move(batch_job_ptr));
// this->timeslots.push_back(batch_job->getEndingTimeStamp());

//remember the allocated resources for the job
batch_job->setAllocatedResources(resources);
Expand All @@ -601,7 +598,6 @@ namespace wrench {
std::unique_ptr<Alarm> alarm_ptr = std::unique_ptr<Alarm>(new Alarm(batch_job->getEndingTimeStamp(), host_to_run_on, this->mailbox_name, msg,
"batch_pilot"));

// this->sent_alrm_msgs.push_back(msg);
this->pilot_job_alarms.push_back(std::move(alarm_ptr));


Expand Down
7 changes: 3 additions & 4 deletions src/wrench/services/helpers/Alarm.cpp
Expand Up @@ -31,14 +31,13 @@ namespace wrench {
*/
Alarm::Alarm(double date, std::string hostname, std::string reply_mailbox_name,
SimulationMessage* msg, std::string suffix):Service("alarm_service_"+suffix,"alarm_service_"+suffix) {

//it would be helpful to debug which service this alarm is for if we pass <compute_service_name> in the suffix=

this->date = date;
if(this->date<=S4U_Simulation::getClock()){
WRENCH_INFO("Alarm is being started but the date to notify is less than current timestamp. will be notified immediately");
}
this->reply_mailbox_name = reply_mailbox_name;
this->msg = msg;
this->msg = std::unique_ptr<SimulationMessage>(msg);
// Start the daemon on the same host
try {
WRENCH_INFO("Alarm Service starting...");
Expand All @@ -63,7 +62,7 @@ namespace wrench {
S4U_Simulation::sleep(time_to_sleep);
try {
S4U_Mailbox::putMessage(this->reply_mailbox_name,
msg);
msg.release());
} catch (std::shared_ptr<NetworkError> cause) {
WRENCH_WARN("AlarmService was not able to send the trigger to its upper service");
}
Expand Down
1 change: 0 additions & 1 deletion test/simulation/StandardJobExecutorTest.cpp
Expand Up @@ -2172,7 +2172,6 @@ class JobTerminationTestAtRandomTimesWMS : public wrench::WMS {
nullptr,
{{wrench::StandardJobExecutorProperty::THREAD_STARTUP_OVERHEAD, "0"}}
);


// Sleep some random number of seconds
double sleep_time = dist(rng);
Expand Down

0 comments on commit 0a7e595

Please sign in to comment.