Код:
#include <glib.h>
int main()
{
typedef struct
{
gint variable;
} __attribute__((__packed__)) test;
//for(i=0; i<100; i++)
{
test* array = g_slice_new(test);
g_slice_free(test, array);
}
}
$ gcc main.c `pkg-config --libs --cflags glib-2.0` -ggdb
$ valgrind ./a.out
==2975== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 17 from 1)
==2975== malloc/free: in use at exit: 4,044 bytes in 8 blocks.
==2975== malloc/free: 8 allocs, 0 frees, 4,044 bytes allocated.
==2975== For counts of detected errors, rerun with: -v
==2975== searching for pointers to 8 not-freed blocks.
==2975== checked 72,016 bytes.
==2975==
==2975== LEAK SUMMARY:
==2975== definitely lost: 0 bytes in 0 blocks.
==2975== possibly lost: 0 bytes in 0 blocks.
==2975== still reachable: 4,044 bytes in 8 blocks.
==2975== suppressed: 0 bytes in 0 blocks.
Откуда появились 4Kb выделенных и потерянных? От glib? Его инициализации?
Форум —
Development