Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix memleak
authorPaul Bédaride <paul.bedaride@gmail.com>
Fri, 22 Nov 2013 16:37:09 +0000 (17:37 +0100)
committerPaul Bédaride <paul.bedaride@gmail.com>
Fri, 22 Nov 2013 16:37:09 +0000 (17:37 +0100)
src/surf/cpu_cas01.cpp
src/surf/cpu_cas01.hpp
src/surf/cpu_ti.cpp
src/surf/cpu_ti.hpp
src/surf/surf_routing.cpp
src/surf/surf_routing_full.cpp
src/surf/workstation_ptask_L07.cpp

index f2a4e8c..8bc8545 100644 (file)
@@ -15,9 +15,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_cas, surf_cpu,
                                 "Logging specific to the SURF CPU IMPROVED module");
 }
 
-static xbt_swag_t
-    cpu_running_action_set_that_does_not_need_being_checked = NULL;
-
 /*************
  * CallBacks *
  *************/
@@ -84,7 +81,7 @@ CpuCas01Model::CpuCas01Model() : CpuModel("cpu")
     xbt_die("Unsupported optimization (%s) for this model", optim);
   }
 
-  cpu_running_action_set_that_does_not_need_being_checked =
+  p_cpuRunningActionSetThatDoesNotNeedBeingChecked =
       xbt_swag_new(xbt_swag_offset(*action, p_stateHookup));
 
   if (p_updateMechanism == UM_LAZY) {
@@ -120,8 +117,7 @@ CpuCas01Model::~CpuCas01Model()
 
   surf_cpu_model_pm = NULL;
 
-  xbt_swag_free(cpu_running_action_set_that_does_not_need_being_checked);
-  cpu_running_action_set_that_does_not_need_being_checked = NULL;
+  xbt_swag_free(p_cpuRunningActionSetThatDoesNotNeedBeingChecked);
 }
 
 void CpuCas01Model::parseInit(sg_platf_host_cbarg_t host)
@@ -338,7 +334,7 @@ ActionPtr CpuCas01Lmm::sleep(double duration)
     /* Move to the *end* of the corresponding action set. This convention
        is used to speed up update_resource_state  */
     xbt_swag_remove(static_cast<ActionPtr>(action), action->p_stateSet);
-    action->p_stateSet = cpu_running_action_set_that_does_not_need_being_checked;
+    action->p_stateSet = static_cast<CpuCas01ModelPtr>(p_model)->p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
     xbt_swag_insert(static_cast<ActionPtr>(action), action->p_stateSet);
   }
 
index 5e12cc2..a75fa9e 100644 (file)
@@ -32,6 +32,7 @@ public:
                           xbt_dict_t cpu_properties);
   double shareResourcesFull(double now);  
   void addTraces();
+  xbt_swag_t p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
 };
 
 /************
index b32b41b..2be282c 100644 (file)
@@ -429,15 +429,6 @@ CpuTiModel::~CpuTiModel()
   xbt_lib_cursor_t cursor;
   char *key;
 
-  xbt_lib_foreach(host_lib, cursor, key, cpu){
-    if(cpu[SURF_CPU_LEVEL])
-    {
-        CpuTiPtr CPU = dynamic_cast<CpuTiPtr>(static_cast<ResourcePtr>(cpu[SURF_CPU_LEVEL]));
-        xbt_swag_free(CPU->p_actionSet);
-        delete CPU->p_availTrace;
-    }
-  }
-
   surf_cpu_model_pm = NULL;
 
   xbt_swag_free
@@ -621,6 +612,11 @@ CpuTi::CpuTi(CpuTiModelPtr model, const char *name, xbt_dynar_t powerPeak,
   }
 };
 
+CpuTi::~CpuTi(){
+delete p_availTrace;
+xbt_swag_free(p_actionSet);
+}
+
 void CpuTi::updateState(tmgr_trace_event_t event_type,
                         double value, double date)
 {
index 6b058f5..eb31b86 100644 (file)
@@ -111,7 +111,7 @@ public:
         int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
        xbt_dict_t properties) ;
-  ~CpuTi() {};
+  ~CpuTi();
 
   void updateState(tmgr_trace_event_t event_type, double value, double date);  
   void updateActionFinishDate(double now);
index 211559d..6216697 100644 (file)
@@ -1263,8 +1263,7 @@ static void finalize_rec(AsPtr as) {
 
 /** \brief Frees all memory allocated by the routing module */
 void routing_exit(void) {
-  if (routing_platf)
-    delete routing_platf;
+  delete routing_platf;
 }
 
 RoutingPlatf::~RoutingPlatf()
index 85551c8..835583f 100644 (file)
@@ -62,8 +62,7 @@ AsFull::~AsFull(){
   for (i = 0; i < table_size; i++)
     for (j = 0; j < table_size; j++) {
       if (TO_ROUTE_FULL(i,j)){
-       if (TO_ROUTE_FULL(i,j)->link_list)
-          xbt_dynar_free(&TO_ROUTE_FULL(i,j)->link_list);
+        xbt_dynar_free(&TO_ROUTE_FULL(i,j)->link_list);
         xbt_free(TO_ROUTE_FULL(i,j));
       }
     }
index 2b7a591..3f9e00e 100644 (file)
@@ -339,7 +339,7 @@ ResourcePtr NetworkL07Model::createResource(const char *name,
                                  e_surf_link_sharing_policy_t
                                  policy, xbt_dict_t properties)
 {
-  LinkL07Ptr nw_link = new LinkL07(this, xbt_strdup(name), properties);
+  LinkL07Ptr nw_link = new LinkL07(this, name, properties);
   xbt_assert(!xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL),
               "Link '%s' declared several times in the platform file.",
               name);