Glib hashtable memory leak



Hello all,

The following program appears to leak memory according to mtrace:

#include <glib.h>
#include <mcheck.h>

int main()
{
        mtrace();

        GHashTable* hash_table;

        hash_table=g_hash_table_new(g_str_hash, g_str_equal);
        g_hash_table_unref (hash_table);

        return 1;
}

I obtain the following result:
$ gcc test1.c -o test1 -I/usr/include/glib-2.0/ -I/usr/lib64/glib-2.0/include/ -lglib-2.0
$ export MALLOC_TRACE=0.mtrace.log
$  ./test1; mtrace ./test1 $MALLOC_TRACE
Memory not freed:
-----------------
           Address     Size     Caller
0x0000000000601460    0x1f8  at 0x3fea834002
0x0000000000601660     0xfc  at 0x3fea834002
0x0000000000601770    0x1f8  at 0x3fea834002
0x0000000000601970    0x7f0  at 0x3fea834002
0x0000000000602400    0x3f0  at 0x3fea8423e1
0x0000000000602800    0x3f0  at 0x3fea8423e1

The docs state that after unref the memory should be freed, so is there anything that I'm doing wrong?

Finally some information on my system:
#uname -a
Linux [host] 2.6.23.15-80.fc7 #1 SMP Sun Feb 10 16:52:18 EST 2008 x86_64 x86_64 x86_64 GNU/Linux

#yum info glib-devel
Name   : glib-devel
Arch   : x86_64
Epoch  : 1
Version: 1.2.10
Release: 26.fc7
Size   : 39 k
Repo   : dks-fedora

Best regards,
Ovidiu


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]