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.
|
* 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_1_size = 40;
|
||||||
static int string_2_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.
|
* 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;
|
else jj->last = new_unit;
|
||||||
|
|
||||||
jj->first = 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)
|
void fsm_publish_log (fsm_log_struct jj)
|
||||||
{
|
{
|
||||||
fsm_log_unit_struct *a_unit = jj.last;
|
fsm_log_unit_struct *a_unit = jj.last;
|
||||||
char buf [LOG_MAX_LENGTH];
|
char buf [LOG_MAX_LENGTH] = { 0 };
|
||||||
int nb = 0;
|
int nb = 0;
|
||||||
while (a_unit)
|
while (a_unit)
|
||||||
{
|
{
|
||||||
strftime(buf, sizeof(buf), "%D %T", localtime(&a_unit->yy_dd_mm));
|
strftime(buf, sizeof(buf), "%D %T", localtime(&a_unit->yy_dd_mm));
|
||||||
|
/*
|
||||||
g_message ("%s + %-6ld %6d %-28s %-32s %-40s",
|
g_message ("%s + %-6ld %6d %-28s %-32s %-40s",
|
||||||
buf,
|
buf,
|
||||||
a_unit->usec,
|
a_unit->usec,
|
||||||
|
@ -158,10 +164,24 @@ void fsm_publish_log (fsm_log_struct jj)
|
||||||
a_unit->file_source,
|
a_unit->file_source,
|
||||||
a_unit->function_source,
|
a_unit->function_source,
|
||||||
a_unit->string_value);
|
a_unit->string_value);
|
||||||
free (a_unit->string_value);
|
*/
|
||||||
|
printf ("%d\n", nb);
|
||||||
a_unit = a_unit->prev;
|
a_unit = a_unit->prev;
|
||||||
nb ++;
|
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
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
13
src/main.c
13
src/main.c
|
@ -63,15 +63,16 @@ int main (int argc, char **argv)
|
||||||
GtkApplication *app;
|
GtkApplication *app;
|
||||||
int status;
|
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);
|
app = gtk_application_new ("org.gem-graph", G_APPLICATION_DEFAULT_FLAGS);
|
||||||
|
|
||||||
|
fsm_init ("first instruction / first log");
|
||||||
|
|
||||||
fsm_add_log (INFO, MAIN, "main",
|
fsm_add_log (INFO, MAIN, "main",
|
||||||
"g signal connect (activate)",
|
"*app = gtk_application_new()",
|
||||||
"| 👉️ windows creation requested");
|
"| 👉️ trigger app initialization");
|
||||||
|
fsm_add_log (INFO, MAIN, "main",
|
||||||
|
"g signal connect (activate)",
|
||||||
|
"| 👉️ windows creation requested");
|
||||||
|
|
||||||
// g_signal_connect (app, "startup", G_CALLBACK (on_windows_startup), NULL);
|
// g_signal_connect (app, "startup", G_CALLBACK (on_windows_startup), NULL);
|
||||||
g_signal_connect (app, "activate", G_CALLBACK (on_app_activation), NULL);
|
g_signal_connect (app, "activate", G_CALLBACK (on_app_activation), NULL);
|
||||||
|
|
Loading…
Reference in New Issue