unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org
Subject: Re: [PATCH] notmuch: unref charset_filter to fix one memory leak
Date: Tue, 13 Dec 2011 17:08:00 +0400	[thread overview]
Message-ID: <877h20wrf3.fsf@gmail.com> (raw)
In-Reply-To: <m2fwgor84q.fsf@guru.guru-group.fi>

On Tue, 13 Dec 2011 14:03:33 +0200, Tomi Ollila <tomi.ollila@iki.fi> wrote:
> In my use case g_object_unref(charset_filter) reduces memory
> consumption over 90% when 'notmuch show --format=text "*"' is
> executed (~11000 messages, RES ~330M -> ~25M).
> ---
>  notmuch-show.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/notmuch-show.c b/notmuch-show.c
> index 873a7c4..23d7368 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -450,6 +450,7 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out)
>  {
>      GMimeContentType *content_type = g_mime_object_get_content_type (GMIME_OBJECT (part));
>      GMimeStream *stream_filter = NULL;
> +    GMimeFilter *charset_filter = NULL;
>      GMimeDataWrapper *wrapper;
>      const char *charset;
>  
> @@ -466,7 +467,6 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out)
>  
>      charset = g_mime_object_get_content_type_parameter (part, "charset");
>      if (charset) {
> -	GMimeFilter *charset_filter;
>  	charset_filter = g_mime_filter_charset_new (charset, "UTF-8");
>  	/* This result can be NULL for things like "unknown-8bit".
>  	 * Don't set a NULL filter as that makes GMime print
> @@ -479,6 +479,8 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out)
>      wrapper = g_mime_part_get_content_object (GMIME_PART (part));
>      if (wrapper && stream_filter)
>  	g_mime_data_wrapper_write_to_stream (wrapper, stream_filter);
> +    if (charset_filter)
> +	g_object_unref (charset_filter);

Why can't we do this inside the if (charset) block?

Regards,
  Dmitry

>      if (stream_filter)
>  	g_object_unref(stream_filter);
>  }
> -- 
> 1.7.6.1
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

  reply	other threads:[~2011-12-13 13:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-13 12:03 [PATCH] notmuch: unref charset_filter to fix one memory leak Tomi Ollila
2011-12-13 13:08 ` Dmitry Kurochkin [this message]
2011-12-13 18:18   ` [PATCH] notmuch: unref charset_filter (once more) " tomi.ollila
2011-12-13 18:24     ` Dmitry Kurochkin
2011-12-15 11:42     ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877h20wrf3.fsf@gmail.com \
    --to=dmitry.kurochkin@gmail.com \
    --cc=notmuch@notmuchmail.org \
    --cc=tomi.ollila@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).