WIP: src/fsm/log/oper.c fsm_publish_log() studying memory leaks with Valgrind
definitely lost: 5,008 bytes in 54 blocks indirectly lost: 16,151 bytes in 673 blocks When g_message() is removed from oper.c fsm_publish_log() no leak seems caused by the gem-graph code.
This commit is contained in:
parent
4df832f342
commit
917886ee6b
|
@ -47,7 +47,7 @@
|
|||
*
|
||||
* Limiting the access to gg_logs helps to avoid uncontrolled operations on it.
|
||||
*/
|
||||
static fsm_log_struct gg_logs;
|
||||
static fsm_log_struct gg_logs = { 0 };
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
static int string_1_size = 40;
|
||||
static int string_2_size = 40;
|
||||
static int string_3_size = 40;
|
||||
static int string_3_size = 50;
|
||||
|
||||
/**
|
||||
* Inits the log: a double chained list.
|
||||
|
@ -128,6 +128,11 @@ void fsm_add_log_event (fsm_log_struct *jj,
|
|||
else jj->last = new_unit;
|
||||
|
||||
jj->first = new_unit;
|
||||
|
||||
free (new_unit->file_source);
|
||||
free (new_unit->function_source);
|
||||
free (new_unit->string_value);
|
||||
// free (new_unit);
|
||||
}
|
||||
|
||||
|
||||
|
@ -146,11 +151,12 @@ void fsm_add_log_event (fsm_log_struct *jj,
|
|||
void fsm_publish_log (fsm_log_struct jj)
|
||||
{
|
||||
fsm_log_unit_struct *a_unit = jj.last;
|
||||
char buf [LOG_MAX_LENGTH];
|
||||
char buf [LOG_MAX_LENGTH] = { 0 };
|
||||
int nb = 0;
|
||||
while (a_unit)
|
||||
{
|
||||
strftime(buf, sizeof(buf), "%D %T", localtime(&a_unit->yy_dd_mm));
|
||||
/*
|
||||
g_message ("%s + %-6ld %6d %-28s %-32s %-40s",
|
||||
buf,
|
||||
a_unit->usec,
|
||||
|
@ -158,10 +164,24 @@ void fsm_publish_log (fsm_log_struct jj)
|
|||
a_unit->file_source,
|
||||
a_unit->function_source,
|
||||
a_unit->string_value);
|
||||
free (a_unit->string_value);
|
||||
*/
|
||||
printf ("%d\n", nb);
|
||||
a_unit = a_unit->prev;
|
||||
nb ++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* LEAK SUMMARY:
|
||||
*
|
||||
* g_message (+) or printf
|
||||
* definitely lost: 5,008 bytes in 54 blocks
|
||||
* indirectly lost: 16,151 bytes in 673 blocks
|
||||
*
|
||||
* g_message (-)
|
||||
* definitely lost: 5,776 bytes in 55 blocks
|
||||
* indirectly lost: 17,703 bytes in 728 blocks
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -63,12 +63,13 @@ int main (int argc, char **argv)
|
|||
GtkApplication *app;
|
||||
int status;
|
||||
|
||||
fsm_init ("first instruction / first log");
|
||||
|
||||
fsm_add_log (INFO, MAIN, "main", "*app = gtk_application_new()",
|
||||
"| 👉️ trigger app initialization");
|
||||
app = gtk_application_new ("org.gem-graph", G_APPLICATION_DEFAULT_FLAGS);
|
||||
|
||||
fsm_init ("first instruction / first log");
|
||||
|
||||
fsm_add_log (INFO, MAIN, "main",
|
||||
"*app = gtk_application_new()",
|
||||
"| 👉️ trigger app initialization");
|
||||
fsm_add_log (INFO, MAIN, "main",
|
||||
"g signal connect (activate)",
|
||||
"| 👉️ windows creation requested");
|
||||
|
|
Loading…
Reference in New Issue