Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Resolve memory leaks
authorPaul Bédaride <paul.bedaride@gmail.com>
Fri, 22 Nov 2013 10:13:43 +0000 (11:13 +0100)
committerPaul Bédaride <paul.bedaride@gmail.com>
Fri, 22 Nov 2013 10:13:43 +0000 (11:13 +0100)
src/surf/cpu_cas01.cpp
src/surf/network.cpp
src/surf/network.hpp
src/surf/surf.cpp
src/surf/surf.hpp
src/surf/surf_routing.cpp
src/surf/surf_routing.hpp
src/surf/surf_routing_full.cpp

index e8d2447..f2a4e8c 100644 (file)
@@ -236,7 +236,6 @@ CpuCas01Lmm::~CpuCas01Lmm(){
   xbt_dynar_free(&p_energy->power_range_watts_list);
   xbt_dynar_free(&p_powerPeakList);
   xbt_free(p_energy);
-  return;
 }
 
 bool CpuCas01Lmm::isUsed()
index 06c517c..a158d7f 100644 (file)
@@ -274,7 +274,8 @@ void NetworkCm02Model::initialize()
   if (!p_maxminSystem)
        p_maxminSystem = lmm_system_new(m_selectiveUpdate);
 
-  routing_model_create(static_cast<ResourcePtr>(createResource("__loopback__",
+  const char* lb_name = "__loopback__";
+  routing_model_create(static_cast<ResourcePtr>(createResource(lb_name,
                                                   498000000, NULL, 0.000015, NULL,
                                                   SURF_RESOURCE_ON, NULL,
                                                   SURF_LINK_FATPIPE, NULL)));
index efc1ba6..fda0c08 100644 (file)
@@ -48,6 +48,13 @@ public:
   NetworkCm02Model() : Model("network") {
     this->initialize();
   }
+  ~NetworkCm02Model() {
+       lmm_system_free(p_maxminSystem);
+       if (p_actionHeap)
+         xbt_heap_free(p_actionHeap);
+       if (p_modifiedSet)
+         xbt_swag_free(p_modifiedSet);
+  }
   //FIXME:NetworkCm02LinkPtr createResource(string name);
   NetworkCm02LinkLmmPtr createResource(const char *name,
                                    double bw_initial,
index 17fe0b0..f0230a0 100644 (file)
@@ -668,8 +668,6 @@ Resource::Resource(surf_model_t model, const char *name, xbt_dict_t props)
 {}
 
 Resource::Resource(){
-  //FIXME:free(m_name);
-  //FIXME:xbt_dict_free(&m_properties);
 }
 
 const char *Resource::getName()
index 8dab3fd..c88ca70 100644 (file)
@@ -167,7 +167,10 @@ class Resource {
 public:
   Resource();
   Resource(ModelPtr model, const char *name, xbt_dict_t properties);
-  virtual ~Resource() {};
+  virtual ~Resource() {
+       xbt_free((void*)m_name);
+       xbt_dict_free(&m_properties);
+  };
 
   virtual void updateState(tmgr_trace_event_t event_type, double value, double date)=0;
 
index e39b3e7..e314b6a 100644 (file)
@@ -397,7 +397,7 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS)
 
   info->p_rcComponent = new_as->p_routingFather;
   info->p_rcType = SURF_NETWORK_ELEMENT_AS;
-  info->p_name = new_as->p_name;
+  info->p_name = xbt_strdup(new_as->p_name);
 
   xbt_lib_set(as_router_lib, info->p_name, ROUTING_ASR_LEVEL,
               (void *) info);
index 2c47691..7d34cbc 100644 (file)
@@ -50,7 +50,9 @@ public:
   xbt_dynar_t p_linkUpDownList;
 
   As(){};
-  virtual ~As(){};
+  virtual ~As(){
+       xbt_free(p_name);
+  };
 
   virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency)=0;
   virtual xbt_dynar_t getOneLinkRoutes()=0;
@@ -70,6 +72,7 @@ public:
 
 struct RoutingEdge {
 public:
+  ~RoutingEdge() { xbt_free(p_name);};
   AsPtr p_rcComponent;
   e_surf_network_element_type_t p_rcType;
   int m_id;
index 23b320f..84b72a7 100644 (file)
@@ -60,8 +60,10 @@ AsFull::~AsFull(){
   int i, j;
   /* Delete routing table */
   for (i = 0; i < table_size; i++)
-    for (j = 0; j < table_size; j++)
+    for (j = 0; j < table_size; j++) {
+      xbt_dynar_free(&TO_ROUTE_FULL(i,j)->link_list);
       xbt_free(TO_ROUTE_FULL(i,j));
+    }
   xbt_free(p_routingTable);
 }