Glib GString: memory not freed ?
- From: Matt <matt flandrescartouches com>
- To: gtk-app-devel-list gnome org
- Subject: Glib GString: memory not freed ?
- Date: Sun, 15 Feb 2004 18:58:12 +0000
Hello,
I am new to glib ;-)
I use mtrace() to find memory leaks in my code and I found something strange
with GStrings : some memory is maybe not freed.
Try the following example:
#include <glib.h>
#include <stdio.h>
#include <mcheck.h>
int main()
{
GString *gstring;
mtrace();
gstring = g_string_new(NULL);
printf("Hello, World!\n");
g_string_sprintf(gstring, ", %s!","World");
printf("Goodbye%s\n",gstring->str);
g_string_free(gstring,TRUE);
muntrace();
return 0;
}
matt:matt$ ./gstring && mtrace ./gstring $MALLOC_TRACE
Hello, World!
Goodbye, World!
Memory not freed:
-----------------
Address Size Caller
0x08051668 0x34 at /tmp/glib-1.2.10/gmem.c:178
0x080516a0 0x8 at /tmp/glib-1.2.10/gmem.c:178
0x080516b0 0x400 at /tmp/glib-1.2.10/gmem.c:178
0x08051ab8 0x34 at /tmp/glib-1.2.10/gmem.c:178
0x08051af0 0x400 at /tmp/glib-1.2.10/gmem.c:178
Looking into the code of gstring.c, I found:
G_LOCK_DEFINE_STATIC (string_mem_chunk);
static GMemChunk *string_mem_chunk = NULL;
Is that data really freed with a g_string_free(gstring,TRUE); ?
Where is my mistake ?
Regards,
Matt
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]