From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 77FD06DE0F40 for ; Mon, 15 Apr 2019 18:46:28 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.025 X-Spam-Level: X-Spam-Status: No, score=-0.025 tagged_above=-999 required=5 tests=[AWL=-0.024, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nej0tmmT0CN7 for ; Mon, 15 Apr 2019 18:46:28 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 925726DE0F5A for ; Mon, 15 Apr 2019 18:46:27 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.89) (envelope-from ) id 1hGDB4-0007pD-Ob; Mon, 15 Apr 2019 21:46:26 -0400 Received: (nullmailer pid 31746 invoked by uid 1000); Tue, 16 Apr 2019 01:46:21 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 1/2] CLI/reindex: fix memory leak Date: Mon, 15 Apr 2019 22:46:15 -0300 Message-Id: <20190416014616.31623-2-david@tethera.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190416014616.31623-1-david@tethera.net> References: <20190416014616.31623-1-david@tethera.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 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, 16 Apr 2019 01:46:28 -0000 Since message is owned by messages, it was held for the entire run of the program. This in turn means that the Xapian::Document objects are not freed, and thus one ends up with (effectively) a copy of one's entire mailstore in memory when running notmuch reindex '*' Thanks to Olly Betts for the patient help debugging, and the suggestion of a fix. --- notmuch-reindex.c | 1 + 1 file changed, 1 insertion(+) diff --git a/notmuch-reindex.c b/notmuch-reindex.c index d8589120..fefa7c63 100644 --- a/notmuch-reindex.c +++ b/notmuch-reindex.c @@ -71,6 +71,7 @@ reindex_query (notmuch_database_t *notmuch, const char *query_string, ret = notmuch_message_reindex(message, indexopts); if (ret != NOTMUCH_STATUS_SUCCESS) break; + notmuch_message_destroy (message); } if (!ret) -- 2.20.1