From: Paul Bédaride Date: Fri, 22 Nov 2013 16:37:09 +0000 (+0100) Subject: Fix memleak X-Git-Tag: v3_11_beta~223 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/be4b540460e5f67714677c3ecf9ff54d2916f0d8 Fix memleak --- diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index f2a4e8c011..8bc85458fb 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -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(action), action->p_stateSet); - action->p_stateSet = cpu_running_action_set_that_does_not_need_being_checked; + action->p_stateSet = static_cast(p_model)->p_cpuRunningActionSetThatDoesNotNeedBeingChecked; xbt_swag_insert(static_cast(action), action->p_stateSet); } diff --git a/src/surf/cpu_cas01.hpp b/src/surf/cpu_cas01.hpp index 5e12cc248a..a75fa9e820 100644 --- a/src/surf/cpu_cas01.hpp +++ b/src/surf/cpu_cas01.hpp @@ -32,6 +32,7 @@ public: xbt_dict_t cpu_properties); double shareResourcesFull(double now); void addTraces(); + xbt_swag_t p_cpuRunningActionSetThatDoesNotNeedBeingChecked; }; /************ diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index b32b41bec2..2be282c2c8 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -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(static_cast(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) { diff --git a/src/surf/cpu_ti.hpp b/src/surf/cpu_ti.hpp index 6b058f5c56..eb31b86fca 100644 --- a/src/surf/cpu_ti.hpp +++ b/src/surf/cpu_ti.hpp @@ -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); diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index 211559d5b1..6216697e01 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -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() diff --git a/src/surf/surf_routing_full.cpp b/src/surf/surf_routing_full.cpp index 85551c8d39..835583fe96 100644 --- a/src/surf/surf_routing_full.cpp +++ b/src/surf/surf_routing_full.cpp @@ -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)); } } diff --git a/src/surf/workstation_ptask_L07.cpp b/src/surf/workstation_ptask_L07.cpp index 2b7a591aaf..3f9e00eefc 100644 --- a/src/surf/workstation_ptask_L07.cpp +++ b/src/surf/workstation_ptask_L07.cpp @@ -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);