Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix memory leaks in msg examples.
authoragiersch <agiersch@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 27 Jan 2011 10:52:03 +0000 (10:52 +0000)
committeragiersch <agiersch@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 27 Jan 2011 10:52:03 +0000 (10:52 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9515 48e7efb5-ca39-0410-a469-dd3cf9ba447f

examples/msg/parallel_task/parallel_task.c
examples/msg/parallel_task/test_ptask.c
examples/msg/priority/priority.c
examples/msg/sendrecv/sendrecv.c
examples/msg/trace/test_trace_integration.c

index 89fc1c1..3a3825c 100644 (file)
@@ -48,6 +48,7 @@ int test(int argc, char *argv[])
                                    communication_amount, NULL);
   MSG_parallel_task_execute(ptask);
 
                                    communication_amount, NULL);
   MSG_parallel_task_execute(ptask);
 
+  MSG_task_destroy(ptask);
   /* There is no need to free that! */
 /*   free(communication_amount); */
 /*   free(computation_amount); */
   /* There is no need to free that! */
 /*   free(communication_amount); */
 /*   free(computation_amount); */
@@ -61,13 +62,16 @@ int test(int argc, char *argv[])
 MSG_error_t test_all(const char *platform_file)
 {
   MSG_error_t res = MSG_OK;
 MSG_error_t test_all(const char *platform_file)
 {
   MSG_error_t res = MSG_OK;
+  m_host_t *hosts;
 
   MSG_config("workstation/model", "ptask_L07");
   MSG_set_channel_number(1);
   MSG_create_environment(platform_file);
 
 
   MSG_config("workstation/model", "ptask_L07");
   MSG_set_channel_number(1);
   MSG_create_environment(platform_file);
 
-  MSG_process_create("test", test, NULL, MSG_get_host_table()[0]);
+  hosts = MSG_get_host_table();
+  MSG_process_create("test", test, NULL, hosts[0]);
   res = MSG_main();
   res = MSG_main();
+  xbt_free(hosts);
 
   INFO1("Simulation time %g", MSG_get_clock());
   return res;
 
   INFO1("Simulation time %g", MSG_get_clock());
   return res;
index b73ab3a..8047d8a 100644 (file)
@@ -72,6 +72,8 @@ int execute(int argc, char *argv[])
 
   execution_time = MSG_get_clock();
   MSG_parallel_task_execute(task);
 
   execution_time = MSG_get_clock();
   MSG_parallel_task_execute(task);
+  MSG_task_destroy(task);
+  xbt_free(m_host_list);
   execution_time = MSG_get_clock() - execution_time;
 
   INFO1("execution_time=%g ", execution_time);
   execution_time = MSG_get_clock() - execution_time;
 
   INFO1("execution_time=%g ", execution_time);
@@ -122,6 +124,8 @@ int redistribute(int argc, char *argv[])
 
   redistribution_time = MSG_get_clock();
   MSG_parallel_task_execute(task);
 
   redistribution_time = MSG_get_clock();
   MSG_parallel_task_execute(task);
+  MSG_task_destroy(task);
+  xbt_free(m_host_list);
   redistribution_time = MSG_get_clock() - redistribution_time;
 
   INFO1("redistribution_time=%g ", redistribution_time);
   redistribution_time = MSG_get_clock() - redistribution_time;
 
   INFO1("redistribution_time=%g ", redistribution_time);
index 1a31157..30ec345 100644 (file)
@@ -32,7 +32,7 @@ static int test(int argc, char *argv[])
   MSG_task_set_priority(task, priority);
 
   MSG_task_execute(task);
   MSG_task_set_priority(task, priority);
 
   MSG_task_execute(task);
-
+  MSG_task_destroy(task);
 
   INFO0("Goodbye now!");
   return 0;
 
   INFO0("Goodbye now!");
   return 0;
index d413535..a16f9cc 100644 (file)
@@ -97,6 +97,7 @@ int receiver(int argc, char *argv[])
     time = sender_time;
     communication_time = time1 - time;
     INFO1("Task received : %s", task_la->name);
     time = sender_time;
     communication_time = time1 - time;
     INFO1("Task received : %s", task_la->name);
+    xbt_free(task_la->data);
     MSG_task_destroy(task_la);
     INFO1("Communic. time %le", communication_time);
     INFO1("--- la %f ----", communication_time);
     MSG_task_destroy(task_la);
     INFO1("Communic. time %le", communication_time);
     INFO1("--- la %f ----", communication_time);
@@ -113,6 +114,7 @@ int receiver(int argc, char *argv[])
     time = sender_time;
     communication_time = time1 - time;
     INFO1("Task received : %s", task_bw->name);
     time = sender_time;
     communication_time = time1 - time;
     INFO1("Task received : %s", task_bw->name);
+    xbt_free(task_bw->data);
     MSG_task_destroy(task_bw);
     INFO1("Communic. time %le", communication_time);
     INFO1("--- bw %f ----", task_comm_size_bw / communication_time);
     MSG_task_destroy(task_bw);
     INFO1("Communic. time %le", communication_time);
     INFO1("--- bw %f ----", task_comm_size_bw / communication_time);
index 057810d..426e182 100644 (file)
@@ -39,6 +39,7 @@ int test_trace(int argc, char *argv[])
   task = MSG_task_create("proc 0", task_comp_size, 0, NULL);
   MSG_task_set_priority(task, task_prio);
   MSG_task_execute(task);
   task = MSG_task_create("proc 0", task_comp_size, 0, NULL);
   MSG_task_set_priority(task, task_prio);
   MSG_task_execute(task);
+  MSG_task_destroy(task);
 
   INFO0("Test finished");
 
 
   INFO0("Test finished");