After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 140548 - Memory leak - GString
Memory leak - GString
Status: RESOLVED DUPLICATE of bug 64096
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2004-04-19 21:50 UTC by David
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description David 2004-04-19 21:50:13 UTC
example code:
-------------
#include <stdio.h>
#include <glib.h>

int main()
{
        GString *gs;
        gs=g_string_new("hello world\n");
        printf(gs->str);
        g_string_free(gs,TRUE);
        return 0;
}

You would expect no memory leaks from this code - however, valgrind -v
--show-reachable=yes --leak-check=yes ./main  will produce the following output,
which appears to be a leak within the glib library itself (2.0.0, debian-unstable)


==3537== 2172 bytes in 5 blocks are still reachable in loss record 1 of 1
==3537==    at 0x3C01F40D: malloc (vg_replace_malloc.c:105)
==3537==    by 0x3C05B161: g_malloc (in /usr/lib/libglib-2.0.so.0.200.3)
==3537==    by 0x3C05BD23: g_mem_chunk_new (in /usr/lib/libglib-2.0.so.0.200.3)
==3537==    by 0x3C069894: g_string_sized_new (in /usr/lib/libglib-2.0.so.0.200.3)
==3537==
==3537== LEAK SUMMARY:
==3537==    definitely lost: 0 bytes in 0 blocks.
==3537==    possibly lost:   0 bytes in 0 blocks.
==3537==    still reachable: 2172 bytes in 5 blocks.
==3537==         suppressed: 0 bytes in 0 blocks.
Comment 1 Owen Taylor 2004-04-21 18:51:21 UTC
'still reachable' "leaks" don't take into account caching.

*** This bug has been marked as a duplicate of 64096 ***