[PATCH] notmuch: unref charset_filter (once more) to fix one memory leak
authortomi.ollila <tomi.ollila@iki.fi>
Tue, 13 Dec 2011 18:18:48 +0000 (20:18 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:40:48 +0000 (09:40 -0800)
c4/80732f5e748f07f02bb416c19bba485d33cf96 [new file with mode: 0644]

diff --git a/c4/80732f5e748f07f02bb416c19bba485d33cf96 b/c4/80732f5e748f07f02bb416c19bba485d33cf96
new file mode 100644 (file)
index 0000000..ccda47b
--- /dev/null
@@ -0,0 +1,78 @@
+Return-Path: <too@guru.guru-group.fi>\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 3BABD429E27\r
+       for <notmuch@notmuchmail.org>; Tue, 13 Dec 2011 10:19:07 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       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 jUQgmt-JDcua for <notmuch@notmuchmail.org>;\r
+       Tue, 13 Dec 2011 10:19:06 -0800 (PST)\r
+Received: from guru.guru-group.fi (guru-group.fi [87.108.86.66])\r
+       by olra.theworths.org (Postfix) with ESMTP id 65722429E25\r
+       for <notmuch@notmuchmail.org>; Tue, 13 Dec 2011 10:19:06 -0800 (PST)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+       id E5A886802B; Tue, 13 Dec 2011 20:19:11 +0200 (EET)\r
+From: tomi.ollila@iki.fi\r
+To: <notmuch@notmuchmail.org>\r
+Subject: [PATCH] notmuch: unref charset_filter (once more) to fix one memory\r
+       leak\r
+Date: Tue, 13 Dec 2011 20:18:48 +0200\r
+Message-Id: <1323800328-17014-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 1.7.6.1\r
+In-Reply-To: <877h20wrf3.fsf@gmail.com>\r
+References: <877h20wrf3.fsf@gmail.com>\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:19:07 -0000\r
+\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
+ 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