From: Martin Quinson Date: Sun, 4 Nov 2018 00:45:07 +0000 (+0100) Subject: plug a memleak X-Git-Tag: v3_22~821 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/4cedb26366276e3045ed070fb6df5b6e6f77967e?hp=27a642fd14257eb01ac3d73d921a135f1e389e24 plug a memleak --- diff --git a/src/simdag/sd_task.cpp b/src/simdag/sd_task.cpp index aa2fb4d337..e75c51c294 100644 --- a/src/simdag/sd_task.cpp +++ b/src/simdag/sd_task.cpp @@ -794,26 +794,14 @@ void SD_task_run(SD_task_t task) XBT_VERB("Executing task '%s'", task->name); - /* Copy the elements of the task into the action */ - int host_nb = task->allocation->size(); - sg_host_t* hosts = new sg_host_t[host_nb]; - std::copy_n(task->allocation->begin(), host_nb, hosts); - - double* flops_amount = new double[host_nb](); - double* bytes_amount = new double[host_nb * host_nb](); - - if(task->flops_amount) - std::copy_n(task->flops_amount, host_nb, flops_amount); - if(task->bytes_amount) - std::copy_n(task->bytes_amount, host_nb * host_nb, bytes_amount); - - task->surf_action = surf_host_model->execute_parallel(host_nb, hosts, flops_amount, bytes_amount, task->rate); + /* Beware! The scheduling data are now used by the surf action directly! no copy was done */ + task->surf_action = surf_host_model->execute_parallel(task->allocation->size(), task->allocation->data(), + task->flops_amount, task->bytes_amount, task->rate); task->surf_action->set_data(task); XBT_DEBUG("surf_action = %p", task->surf_action); - __SD_task_destroy_scheduling_data(task); /* now the scheduling data are not useful anymore */ SD_task_set_state(task, SD_RUNNING); sd_global->return_set->insert(task); } diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 5943f79ddb..1bf76de1f0 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -187,9 +187,11 @@ L07Action::L07Action(kernel::resource::Model* model, int host_nb, sg_host_t* hos if (latency_ > 0) model->get_maxmin_system()->update_variable_weight(get_variable(), 0.0); - if (flops_amount != nullptr) - for (int i = 0; i < host_nb; i++) - model->get_maxmin_system()->expand(host_list[i]->pimpl_cpu->get_constraint(), get_variable(), flops_amount[i]); + /* Expend it for the CPUs even if there is nothing to compute, to make sure that it gets expended even if there is no + * communication either */ + for (int i = 0; i < host_nb; i++) + model->get_maxmin_system()->expand(host_list[i]->pimpl_cpu->get_constraint(), get_variable(), + (flops_amount == nullptr ? 0.0 : flops_amount[i])); if (bytes_amount != nullptr) { for (int i = 0; i < host_nb; i++) {