From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: joakim@verona.se Newsgroups: gmane.emacs.devel Subject: Re: Using the ImageMagick backend seems to leak memory Date: Tue, 11 Jan 2011 15:38:17 +0100 Message-ID: References: <87sjx6zczl.fsf@member.fsf.org> <30611405.post@talk.nabble.com> <874o9l86eb.fsf@member.fsf.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1294756720 9277 80.91.229.12 (11 Jan 2011 14:38:40 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 11 Jan 2011 14:38:40 +0000 (UTC) Cc: Miles Bader , Jashy , Emacs-devel@gnu.org To: Tassilo Horn Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jan 11 15:38:35 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 1PcfMn-0007fC-V8 for ged-emacs-devel@m.gmane.org; Tue, 11 Jan 2011 15:38:34 +0100 Original-Received: from localhost ([127.0.0.1]:35804 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PcfMn-0004XD-9H for ged-emacs-devel@m.gmane.org; Tue, 11 Jan 2011 09:38:33 -0500 Original-Received: from [140.186.70.92] (port=34175 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PcfMd-0004Ug-JX for Emacs-devel@gnu.org; Tue, 11 Jan 2011 09:38:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PcfMc-00018h-4A for Emacs-devel@gnu.org; Tue, 11 Jan 2011 09:38:23 -0500 Original-Received: from batman.blixtvik.net ([87.96.254.3]:34632) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PcfMb-00018R-NH; Tue, 11 Jan 2011 09:38:22 -0500 Original-Received: from www.verona.se (4-208-96-87.cust.blixtvik.se [87.96.208.4]) by batman.blixtvik.net (Postfix) with ESMTP id C73907F9451; Tue, 11 Jan 2011 15:38:19 +0100 (CET) Original-Received: from localhost.localdomain (unknown [192.168.201.6]) by www.verona.se (Postfix) with ESMTP id 1829196B077; Tue, 11 Jan 2011 15:38:19 +0100 (CET) In-Reply-To: (joakim@verona.se's message of "Tue, 11 Jan 2011 15:17:06 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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:134446 Archived-At: joakim@verona.se writes: > Tassilo Horn writes: Could you try this patch? Seems to help for me === modified file 'src/image.c' *** src/image.c 2011-01-07 22:33:32 +0000 --- src/image.c 2011-01-11 14:30:55 +0000 *************** *** 7566,7571 **** --- 7566,7572 ---- if (im_image != NULL) { image_wand = NewMagickWandFromImage (im_image); + DestroyImage(im_image); status = MagickTrue; } else > >> 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 >> >> 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. >> >> In the emacs sources, that function's never called. So that's probably >> the source of the leak. > > Hmm. We can try. > > Anyway i asked the IM team: > http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=17819 > > Some other things: > - Do you see the issue only when scaling? > - Only with PNG? Or also JPG? > >> Bye, >> Tassilo -- Joakim Verona