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 E57B6429E26 for ; Tue, 13 Dec 2011 05:08:41 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 Eb5MToRONYHA for ; Tue, 13 Dec 2011 05:08:41 -0800 (PST) Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com [74.125.83.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id B9094429E25 for ; Tue, 13 Dec 2011 05:08:40 -0800 (PST) Received: by eekd41 with SMTP id d41so2052288eek.26 for ; Tue, 13 Dec 2011 05:08:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:in-reply-to:references:user-agent:date:message-id :mime-version:content-type; bh=oQObe0aD9tYWXdRdqnl7erdljjOIowvgnwQcOftRMps=; b=aCEiszv4fDJvDryG7d5SyO0yfgSFILKuSPkCR5vuxtjM4Y8+lE0d+2cuASGmXL6a40 muK2GeHfp9BZT5zA7zVwOryNT84EBVJnLaN2OWbGoXzAG7wjrbx9RFaA+D0GyFWdVCvU eQ8KkiGtgThBGPW9bt4eNalFwCjLwsXP6pwS0= Received: by 10.14.2.136 with SMTP id 8mr3737420eef.132.1323781717855; Tue, 13 Dec 2011 05:08:37 -0800 (PST) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id 54sm10104674eeo.10.2011.12.13.05.08.36 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 13 Dec 2011 05:08:37 -0800 (PST) From: Dmitry Kurochkin To: Tomi Ollila , notmuch@notmuchmail.org Subject: Re: [PATCH] notmuch: unref charset_filter to fix one memory leak In-Reply-To: References: User-Agent: Notmuch/0.10.2+94~g948b41d (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Tue, 13 Dec 2011 17:08:00 +0400 Message-ID: <877h20wrf3.fsf@gmail.com> 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 13:08:42 -0000 On Tue, 13 Dec 2011 14:03:33 +0200, Tomi Ollila 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