From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: Using the ImageMagick backend seems to leak memory Date: Fri, 07 Jan 2011 09:28:12 +0100 Message-ID: <874o9l86eb.fsf@member.fsf.org> References: <87sjx6zczl.fsf@member.fsf.org> <30611405.post@talk.nabble.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1294388911 5214 80.91.229.12 (7 Jan 2011 08:28:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 7 Jan 2011 08:28:31 +0000 (UTC) Cc: Jashy , Emacs-devel@gnu.org To: Miles Bader Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jan 07 09:28:27 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Pb7gR-00016v-2C for ged-emacs-devel@m.gmane.org; Fri, 07 Jan 2011 09:28:27 +0100 Original-Received: from localhost ([127.0.0.1]:34879 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pb7gN-0007Mw-AF for ged-emacs-devel@m.gmane.org; Fri, 07 Jan 2011 03:28:23 -0500 Original-Received: from [140.186.70.92] (port=41414 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pb7gG-0007Ly-5V for Emacs-devel@gnu.org; Fri, 07 Jan 2011 03:28:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pb7gE-0002IU-RS for Emacs-devel@gnu.org; Fri, 07 Jan 2011 03:28:15 -0500 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]:16086) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pb7gE-0002IM-Mk; Fri, 07 Jan 2011 03:28:14 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by deliver.uni-koblenz.de (Postfix) with ESMTP id 450E878016CA; Fri, 7 Jan 2011 09:28:13 +0100 (CET) Original-Received: from deliver.uni-koblenz.de ([127.0.0.1]) by localhost (deliver.uni-koblenz.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 22480-08; Fri, 7 Jan 2011 09:28:12 +0100 (CET) X-CHKRCPT: Envelopesender noch tassilo@member.fsf.org Original-Received: from thinkpad (tsdh.uni-koblenz.de [141.26.67.142]) by deliver.uni-koblenz.de (Postfix) with ESMTP id 69F8B78016C8; Fri, 7 Jan 2011 09:28:12 +0100 (CET) In-Reply-To: (Miles Bader's message of "Fri, 07 Jan 2011 13:59:46 +0900") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) X-Virus-Scanned: amavisd-new at uni-koblenz.de X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:134349 Archived-At: Miles Bader writes: >>> I just noticed that my emacs uses up more than a gigabyte memory. >>> It is because of doc-view with ImageMagick backend. >>> >> I met same issue. > > My impression is that in general, ImageMagick does not aim at memory > efficiency (that's why I don't want to use its libraries for my own > image I/O needs, event though doing so would be pretty convenient). Well, not being memory efficiency and not giving back memory at all is a minor difference. ;-) I've just opened a doc-view page-x.png with ImageMagick's display tool. The behavior is identical, e.g., it reserves ~30MB per PNG and only gives back memory when I close the program. So I presume, ImageMagick has some cache that gets at least cleared when the process is killed. I'm sure, there's some C function you can call to clear it... Looking at the API, there's --8<---------------cut here---------------start------------->8--- ClearMagickWand() clears resources associated with the wand. The format of the ClearMagickWand method is: void ClearMagickWand(MagickWand *wand) A description of each parameter follows: wand the magick wand. --8<---------------cut here---------------end--------------->8--- In the emacs sources, that function's never called. So that's probably the source of the leak. Bye, Tassilo