unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] notmuch: unref charset_filter to fix one memory leak
@ 2011-12-13 12:03 Tomi Ollila
  2011-12-13 13:08 ` Dmitry Kurochkin
  0 siblings, 1 reply; 5+ messages in thread
From: Tomi Ollila @ 2011-12-13 12:03 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-12-15 11:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-13 12:03 [PATCH] notmuch: unref charset_filter to fix one memory leak Tomi Ollila
2011-12-13 13:08 ` Dmitry Kurochkin
2011-12-13 18:18   ` [PATCH] notmuch: unref charset_filter (once more) " tomi.ollila
2011-12-13 18:24     ` Dmitry Kurochkin
2011-12-15 11:42     ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).