From: Paul Bédaride Date: Thu, 9 Jan 2014 15:26:28 +0000 (+0100) Subject: Memleaks fixes on VM X-Git-Tag: v3_11_beta~155 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/c2f2254d18ea12282dbc23cc2ff196be1ed89423?hp=abe3765d08e007c310d44c9eec557b47af593984 Memleaks fixes on VM --- diff --git a/src/msg/msg_vm.c b/src/msg/msg_vm.c index ff506761d4..095480a18d 100644 --- a/src/msg/msg_vm.c +++ b/src/msg/msg_vm.c @@ -890,7 +890,6 @@ static double send_stage1(msg_host_t vm, const char *src_pm_name, const char *ds remaining -= datasize; send_migration_data(vm_name, src_pm_name, dst_pm_name, datasize, mbox, 1, 0, mig_speed, xfer_cpu_overhead); - double computed = lookup_computed_flop_counts(vm, 1, 0); computed_total += computed; @@ -901,7 +900,7 @@ static double send_stage1(msg_host_t vm, const char *src_pm_name, const char *ds // launch_deferred_exec_process(vm, overhead, 10000); // } } - + xbt_free(mbox); return computed_total; } @@ -1098,11 +1097,13 @@ static void do_migration(msg_vm_t vm, msg_host_t src_pm, msg_host_t dst_pm) { msg_task_t task = NULL; msg_error_t ret = MSG_task_recv(&task, mbox_ctl); + xbt_assert(ret == MSG_OK); char *expected_task_name = get_mig_task_name(sg_host_name(vm), sg_host_name(src_pm), sg_host_name(dst_pm), 4); xbt_assert(strcmp(task->name, expected_task_name) == 0); xbt_free(expected_task_name); + MSG_task_destroy(task); } xbt_free(mbox_ctl); diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index b26d58bc09..b496745025 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -149,13 +149,14 @@ Cpu::Cpu(ModelPtr model, const char *name, xbt_dict_t props, } Cpu::~Cpu(){ - if (getModel()->getUpdateMechanism() != UM_UNDEFINED){ + if (p_constraintCoreId){ for (int i = 0; i < m_core; i++) { xbt_free(p_constraintCoreId[i]); } xbt_free(p_constraintCore); - xbt_free(p_constraintCoreId); } + if (p_constraintCoreId) + xbt_free(p_constraintCoreId); } double Cpu::getSpeed(double load) diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 1aeddb80e0..20622d15b7 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -1015,6 +1015,11 @@ double Action::getRemains() return m_remains; } +double Action::getRemainsNoUpdate() +{ + return m_remains; +} + //FIXME split code in the right places void Action::updateRemainingLazy(double now) { diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 2558c9ea8e..741e1555f1 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -289,11 +289,12 @@ public: void setCategory(const char *category); /**< Set the category of an action */ #endif virtual double getRemains(); /**< Get the remains of an action */ + double getRemainsNoUpdate(); + #ifdef HAVE_LATENCY_BOUND_TRACKING int getLatencyLimited(); /**< Return 1 if action is limited by latency, 0 otherwise */ #endif - double getPriority() {return m_priority;}; ActionListPtr getStateSet() {return p_stateSet;}; diff --git a/src/surf/vm_workstation_hl13.cpp b/src/surf/vm_workstation_hl13.cpp index f0367303fd..bb6add4ed6 100644 --- a/src/surf/vm_workstation_hl13.cpp +++ b/src/surf/vm_workstation_hl13.cpp @@ -321,7 +321,7 @@ WorkstationVMHL13::~WorkstationVMHL13() xbt_assert(ret == 1, "Bug: some resource still remains"); /* Free the cpu resource of the VM. If using power_trace, we will have to */ - delete cpu; + //delete cpu; /* Free the network resource of the VM. */ // Nothing has to be done, because net_elmts is just a pointer on the physical one @@ -429,8 +429,8 @@ void WorkstationVMHL13::migrate(surf_resource_t ind_dst_pm) e_surf_action_state_t state = p_action->getState(); if (state != SURF_ACTION_DONE) XBT_CRITICAL("FIXME: may need a proper handling, %d", state); - if (p_action->getRemains() > 0) - XBT_CRITICAL("FIXME: need copy the state(?), %f", p_action->getRemains()); + if (p_action->getRemainsNoUpdate() > 0) + XBT_CRITICAL("FIXME: need copy the state(?), %f", p_action->getRemainsNoUpdate()); int ret = p_action->unref(); xbt_assert(ret == 1, "Bug: some resource still remains"); diff --git a/src/surf/vm_workstation_interface.cpp b/src/surf/vm_workstation_interface.cpp index 69f6c67fc2..7a24d2d04e 100644 --- a/src/surf/vm_workstation_interface.cpp +++ b/src/surf/vm_workstation_interface.cpp @@ -30,32 +30,6 @@ WorkstationVMModel::WorkstationVMModel() : WorkstationModel("Virtual Workstation */ WorkstationVM::~WorkstationVM() { - /* ind_phys_workstation equals to smx_host_t */ - surf_resource_t ind_vm_workstation = xbt_lib_get_elm_or_null(host_lib, getName()); - - /* Before clearing the entries in host_lib, we have to pick up resources. */ - CpuCas01Ptr cpu = static_cast(surf_cpu_resource_priv(ind_vm_workstation)); - - /* We deregister objects from host_lib, without invoking the freeing callback - * of each level. - * - * Do not call xbt_lib_remove() here. It deletes all levels of the key, - * including MSG_HOST_LEVEL and others. We should unregister only what we know. - */ - xbt_lib_unset(host_lib, getName(), SURF_CPU_LEVEL, 0); - xbt_lib_unset(host_lib, getName(), ROUTING_HOST_LEVEL, 0); - xbt_lib_unset(host_lib, getName(), SURF_WKS_LEVEL, 0); - - /* TODO: comment out when VM stroage is implemented. */ - // xbt_lib_unset(host_lib, name, SURF_STORAGE_LEVEL, 0); - - - /* Free the cpu_action of the VM. */ - int ret = p_action->unref(); - xbt_assert(ret == 1, "Bug: some resource still remains"); - - /* Free the cpu resource of the VM. If using power_trace, we will have to */ - delete cpu; } /*