GNOME Bugzilla – Bug 140548
Memory leak - GString
Last modified: 2004-12-22 21:47:04 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.
'still reachable' "leaks" don't take into account caching. *** This bug has been marked as a duplicate of 64096 ***