Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Memleaks fixes on VM
authorPaul Bédaride <paul.bedaride@gmail.com>
Thu, 9 Jan 2014 15:26:28 +0000 (16:26 +0100)
committerPaul Bédaride <paul.bedaride@gmail.com>
Thu, 9 Jan 2014 15:26:28 +0000 (16:26 +0100)
src/msg/msg_vm.c
src/surf/cpu_interface.cpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp
src/surf/vm_workstation_hl13.cpp
src/surf/vm_workstation_interface.cpp

index ff50676..095480a 100644 (file)
@@ -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);
index b26d58b..b496745 100644 (file)
@@ -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)
index 1aeddb8..20622d1 100644 (file)
@@ -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)
 {
index 2558c9e..741e155 100644 (file)
@@ -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;};
 
index f036730..bb6add4 100644 (file)
@@ -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");
index 69f6c67..7a24d2d 100644 (file)
@@ -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<CpuCas01Ptr>(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;
 }
 
 /*