Jan 252006

I just completed reworking the GSlice and g_malloc() memory debugging hooks. With this, GLib-2.10 (or the next GLib-2.9 development version due this weekend) will (without recompilation) support G_SLICE=always-malloc and G_DEBUG=gc-friendly. These cause all GSlice allocations to go through g_malloc() and g_free() instead and cause all released memory to be memset() to 0. This helps memory checkers to trace pointer lists and can be used to debug g_malloc()/g_free() and g_slice_new()/g_slice_free() allocation code to find and plug memory leaks:

	G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --leak-check=full mybuggyprogram

Or, in combination with MALLOC_CHECK_, it can be used to catch and debug invalid allocation/release calls:

	G_SLICE=always-malloc G_DEBUG=gc-friendly MALLOC_CHECK_=2 gdb mybuggyprogram

Tweet about this on TwitterShare on Google+Share on LinkedInShare on FacebookFlattr the authorBuffer this pageShare on RedditDigg thisShare on VKShare on YummlyPin on PinterestShare on StumbleUponShare on TumblrPrint this pageEmail this to someone

  One Response to “25.01.2006 Allocation debugging with GLib”

  1. Hi,

    it would be really nice to add this info to the documentation instead then only posting it on a blog 🙂


 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>