瀏覽代碼

fix memleaks

Samuel Thibault 8 年之前
父節點
當前提交
84e795a1db

+ 1 - 0
sc_hypervisor/src/hypervisor_policies/ispeed_lp_policy.c

@@ -177,6 +177,7 @@ static void _try_resizing(unsigned *sched_ctxs, int nsched_ctxs , int *workers,
 		
 		sc_hypervisor_lp_redistribute_resources_in_ctxs(ns, ntypes_of_workers, nworkers_per_ctx_rounded, nworkers_per_ctx, curr_sched_ctxs, tw);
 	}
+	free(tw);
 	for(i = 0; i < ns; i++)
 		free(flops_on_w[i]);
 	free(flops_on_w);

+ 3 - 1
sc_hypervisor/src/policies_utils/lp_tools.c

@@ -327,7 +327,9 @@ double sc_hypervisor_lp_get_tmax(int nworkers, int *workers)
 	int nsched_ctxs = sc_hypervisor_get_nsched_ctxs();
 
 	double res[nsched_ctxs][nw];
-	return sc_hypervisor_lp_get_nworkers_per_ctx(nsched_ctxs, nw, res, total_nw, tw, NULL) * 1000.0;
+	double ret = sc_hypervisor_lp_get_nworkers_per_ctx(nsched_ctxs, nw, res, total_nw, tw, NULL) * 1000.0;
+	free(tw);
+	return ret;
 }
 
 void sc_hypervisor_lp_round_double_to_int(int ns, int nw, double res[ns][nw], int res_rounded[ns][nw])

+ 1 - 0
sc_hypervisor/src/policies_utils/policy_tools.c

@@ -530,6 +530,7 @@ unsigned sc_hypervisor_check_speed_gap_btw_ctxs(unsigned *sched_ctxs_in, int ns_
 			}
 			has_opt_v = 1;
 		}
+		free(tw);
 	}
 
 /* if we have an optimal speed for each type of worker compare the monitored one with the

+ 3 - 0
sc_hypervisor/src/policies_utils/speed.c

@@ -300,7 +300,10 @@ void sc_hypervisor_check_if_consider_max(struct types_of_workers *tw)
 	{
 		avg_speed_per_tw[w] = sc_hypervisor_get_avg_speed(sc_hypervisor_get_arch_for_index(w, tw));
 		if(avg_speed_per_tw[w] == -1.0)
+		{
+			free(sched_ctxs);
 			return;
+		}
 	}
 
 	int s;