[PATCH] notmuch: unref charset_filter (once more) to fix one memory leak

Dmitry Kurochkin dmitry.kurochkin at gmail.com
Tue Dec 13 10:24:11 PST 2011


On Tue, 13 Dec 2011 20:18:48 +0200, tomi.ollila at iki.fi wrote:
> From: Tomi Ollila <tomi.ollila at iki.fi>
> 
> In my test case added g_object_unref(charset_filter) reduces memory
> consumption over 90% when 'notmuch show --format=text "*"' is
> executed (~11000 messages, RES ~330M -> ~25M).
> ---
> Thanks Dmitry. I did not realize unref unreferences, does not deallocate
> memory/data structures. g_mime_stream_filter_add() takes an additional
> reference to the charset_filter object.

Looks good to me.

Regards,
  Dmitry

>  notmuch-show.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/notmuch-show.c b/notmuch-show.c
> index 873a7c4..8da3295 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -471,9 +471,12 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out)
>  	/* This result can be NULL for things like "unknown-8bit".
>  	 * Don't set a NULL filter as that makes GMime print
>  	 * annoying assertion-failure messages on stderr. */
> -	if (charset_filter)
> +	if (charset_filter) {
>  	    g_mime_stream_filter_add (GMIME_STREAM_FILTER (stream_filter),
>  				      charset_filter);
> +	    g_object_unref (charset_filter);
> +	}
> +
>      }
>  
>      wrapper = g_mime_part_get_content_object (GMIME_PART (part));
> -- 
> 1.7.6.1
> 
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


More information about the notmuch mailing list