Re: [PATCH] notmuch: unref charset_filter (once more) to fix one memory leak
authorDmitry Kurochkin <dmitry.kurochkin@gmail.com>
Tue, 13 Dec 2011 18:24:11 +0000 (22:24 +0400)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:40:48 +0000 (09:40 -0800)
ab/ebbdff4022da741f7ba54c9777f2f57387fce8 [new file with mode: 0644]

diff --git a/ab/ebbdff4022da741f7ba54c9777f2f57387fce8 b/ab/ebbdff4022da741f7ba54c9777f2f57387fce8
new file mode 100644 (file)
index 0000000..6ed8091
--- /dev/null
@@ -0,0 +1,109 @@
+Return-Path: <dmitry.kurochkin@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 78017429E27\r
+       for <notmuch@notmuchmail.org>; Tue, 13 Dec 2011 10:24:51 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 0PHJGqyJevKy for <notmuch@notmuchmail.org>;\r
+       Tue, 13 Dec 2011 10:24:51 -0800 (PST)\r
+Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com\r
+       [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id B773F429E25\r
+       for <notmuch@notmuchmail.org>; Tue, 13 Dec 2011 10:24:50 -0800 (PST)\r
+Received: by faaa5 with SMTP id a5so475744faa.26\r
+       for <notmuch@notmuchmail.org>; Tue, 13 Dec 2011 10:24:49 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=from:to:cc:subject:in-reply-to:references:user-agent:date\r
+       :message-id:mime-version:content-type;\r
+       bh=0bYYEpqs72Qw5usXcqKQ3nmvpqSuSJw3NOR6dPAOUpk=;\r
+       b=syP9fTnK8PM7Yv9jqmwwOfhrya2GbRcmM/rnGmB0opBm8CcyUgn6XN+yjlhMjDa7Oz\r
+       xOCAXP+ud2i2ZS7WYHAPzzwP++2wsajCt/LDSstyKwAyytLPp+pP+YVc2tbUoDctjZK5\r
+       JubwUFuNrOMQFydK5czfRLILrmWWZBnba+k+8=\r
+Received: by 10.216.132.164 with SMTP id o36mr3309975wei.76.1323800689107;\r
+       Tue, 13 Dec 2011 10:24:49 -0800 (PST)\r
+Received: from localhost ([91.144.186.21])\r
+       by mx.google.com with ESMTPS id dd4sm30874971wib.1.2011.12.13.10.24.47\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Tue, 13 Dec 2011 10:24:48 -0800 (PST)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: tomi.ollila@iki.fi, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] notmuch: unref charset_filter (once more) to fix one\r
+       memory leak\r
+In-Reply-To: <1323800328-17014-1-git-send-email-tomi.ollila@iki.fi>\r
+References: <877h20wrf3.fsf@gmail.com>\r
+       <1323800328-17014-1-git-send-email-tomi.ollila@iki.fi>\r
+User-Agent: Notmuch/0.10.2+96~g74e5ae5 (http://notmuchmail.org) Emacs/23.3.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Tue, 13 Dec 2011 22:24:11 +0400\r
+Message-ID: <87wra0uy7o.fsf@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Cc: Tomi Ollila <tomi.ollila@iki.fi>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 13 Dec 2011 18:24:51 -0000\r
+\r
+On Tue, 13 Dec 2011 20:18:48 +0200, tomi.ollila@iki.fi wrote:\r
+> From: Tomi Ollila <tomi.ollila@iki.fi>\r
+> \r
+> In my test case added g_object_unref(charset_filter) reduces memory\r
+> consumption over 90% when 'notmuch show --format=text "*"' is\r
+> executed (~11000 messages, RES ~330M -> ~25M).\r
+> ---\r
+> Thanks Dmitry. I did not realize unref unreferences, does not deallocate\r
+> memory/data structures. g_mime_stream_filter_add() takes an additional\r
+> reference to the charset_filter object.\r
+\r
+Looks good to me.\r
+\r
+Regards,\r
+  Dmitry\r
+\r
+>  notmuch-show.c |    5 ++++-\r
+>  1 files changed, 4 insertions(+), 1 deletions(-)\r
+> \r
+> diff --git a/notmuch-show.c b/notmuch-show.c\r
+> index 873a7c4..8da3295 100644\r
+> --- a/notmuch-show.c\r
+> +++ b/notmuch-show.c\r
+> @@ -471,9 +471,12 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out)\r
+>      /* This result can be NULL for things like "unknown-8bit".\r
+>       * Don't set a NULL filter as that makes GMime print\r
+>       * annoying assertion-failure messages on stderr. */\r
+> -    if (charset_filter)\r
+> +    if (charset_filter) {\r
+>          g_mime_stream_filter_add (GMIME_STREAM_FILTER (stream_filter),\r
+>                                    charset_filter);\r
+> +        g_object_unref (charset_filter);\r
+> +    }\r
+> +\r
+>      }\r
+>  \r
+>      wrapper = g_mime_part_get_content_object (GMIME_PART (part));\r
+> -- \r
+> 1.7.6.1\r
+> \r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r