Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id E403B429E26 for ; Tue, 13 Dec 2011 04:03:29 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fJaYYAqWQnZX for ; Tue, 13 Dec 2011 04:03:29 -0800 (PST) Received: from guru.guru-group.fi (guru-group.fi [87.108.86.66]) by olra.theworths.org (Postfix) with ESMTP id 4BBF3429E25 for ; Tue, 13 Dec 2011 04:03:29 -0800 (PST) Received: by guru.guru-group.fi (Postfix, from userid 501) id 689A76802B; Tue, 13 Dec 2011 14:03:33 +0200 (EET) From: Tomi Ollila To: Subject: [PATCH] notmuch: unref charset_filter to fix one memory leak User-Agent: Notmuch/0.10.2+91~gcaae152 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-unknown-linux-gnu) Date: Tue, 13 Dec 2011 14:03:33 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Dec 2011 12:03:30 -0000 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); if (stream_filter) g_object_unref(stream_filter); } -- 1.7.6.1