[PATCH] Minor style changes.
[notmuch-archives.git] / 57 / e38880c74609b0424c758d27dd274efd1c11d9
1 Return-Path: <too@iki.fi>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id E403B429E26\r
6         for <notmuch@notmuchmail.org>; Tue, 13 Dec 2011 04:03:29 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id fJaYYAqWQnZX for <notmuch@notmuchmail.org>;\r
16         Tue, 13 Dec 2011 04:03:29 -0800 (PST)\r
17 Received: from guru.guru-group.fi (guru-group.fi [87.108.86.66])\r
18         by olra.theworths.org (Postfix) with ESMTP id 4BBF3429E25\r
19         for <notmuch@notmuchmail.org>; Tue, 13 Dec 2011 04:03:29 -0800 (PST)\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
21         id 689A76802B; Tue, 13 Dec 2011 14:03:33 +0200 (EET)\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>\r
23 To: <notmuch@notmuchmail.org>\r
24 Subject: [PATCH] notmuch: unref charset_filter to fix one memory leak\r
25 User-Agent: Notmuch/0.10.2+91~gcaae152 (http://notmuchmail.org) Emacs/23.3.1\r
26         (x86_64-unknown-linux-gnu)\r
27 Date: Tue, 13 Dec 2011 14:03:33 +0200\r
28 Message-ID: <m2fwgor84q.fsf@guru.guru-group.fi>\r
29 MIME-Version: 1.0\r
30 Content-Type: text/plain; charset=us-ascii\r
31 X-BeenThere: notmuch@notmuchmail.org\r
32 X-Mailman-Version: 2.1.13\r
33 Precedence: list\r
34 List-Id: "Use and development of the notmuch mail system."\r
35         <notmuch.notmuchmail.org>\r
36 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
37         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
38 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
39 List-Post: <mailto:notmuch@notmuchmail.org>\r
40 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
41 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
42         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
43 X-List-Received-Date: Tue, 13 Dec 2011 12:03:30 -0000\r
44 \r
45 In my use case g_object_unref(charset_filter) reduces memory\r
46 consumption over 90% when 'notmuch show --format=text "*"' is\r
47 executed (~11000 messages, RES ~330M -> ~25M).\r
48 ---\r
49  notmuch-show.c |    4 +++-\r
50  1 files changed, 3 insertions(+), 1 deletions(-)\r
51 \r
52 diff --git a/notmuch-show.c b/notmuch-show.c\r
53 index 873a7c4..23d7368 100644\r
54 --- a/notmuch-show.c\r
55 +++ b/notmuch-show.c\r
56 @@ -450,6 +450,7 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out)\r
57  {\r
58      GMimeContentType *content_type = g_mime_object_get_content_type (GMIME_OBJECT (part));\r
59      GMimeStream *stream_filter = NULL;\r
60 +    GMimeFilter *charset_filter = NULL;\r
61      GMimeDataWrapper *wrapper;\r
62      const char *charset;\r
63  \r
64 @@ -466,7 +467,6 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out)\r
65  \r
66      charset = g_mime_object_get_content_type_parameter (part, "charset");\r
67      if (charset) {\r
68 -       GMimeFilter *charset_filter;\r
69         charset_filter = g_mime_filter_charset_new (charset, "UTF-8");\r
70         /* This result can be NULL for things like "unknown-8bit".\r
71          * Don't set a NULL filter as that makes GMime print\r
72 @@ -479,6 +479,8 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out)\r
73      wrapper = g_mime_part_get_content_object (GMIME_PART (part));\r
74      if (wrapper && stream_filter)\r
75         g_mime_data_wrapper_write_to_stream (wrapper, stream_filter);\r
76 +    if (charset_filter)\r
77 +       g_object_unref (charset_filter);\r
78      if (stream_filter)\r
79         g_object_unref(stream_filter);\r
80  }\r
81 -- \r
82 1.7.6.1\r