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 19:11:48 +0100 Message-ID: References: <87sjx6zczl.fsf@member.fsf.org> <30611405.post@talk.nabble.com> <874o9l86eb.fsf@member.fsf.org> <87zkr7nxo8.fsf@member.fsf.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1294769527 17748 80.91.229.12 (11 Jan 2011 18:12:07 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 11 Jan 2011 18:12:07 +0000 (UTC) Cc: Emacs-devel@gnu.org, Jashy , Miles Bader To: Tassilo Horn Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jan 11 19:12:02 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 1PcihO-0002ry-3b for ged-emacs-devel@m.gmane.org; Tue, 11 Jan 2011 19:12:02 +0100 Original-Received: from localhost ([127.0.0.1]:57754 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PcihN-0004gf-Fb for ged-emacs-devel@m.gmane.org; Tue, 11 Jan 2011 13:12:01 -0500 Original-Received: from [140.186.70.92] (port=44697 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PcihJ-0004gN-1M for Emacs-devel@gnu.org; Tue, 11 Jan 2011 13:11:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PcihI-0005aW-7b for Emacs-devel@gnu.org; Tue, 11 Jan 2011 13:11:56 -0500 Original-Received: from iwfs.imcode.com ([82.115.149.64]:45835 helo=gate.verona.se) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PcihF-0005ZH-Rl; Tue, 11 Jan 2011 13:11:54 -0500 Original-Received: from localhost.localdomain (IDENT:1005@localhost [127.0.0.1]) by gate.verona.se (8.13.4/8.11.4) with ESMTP id p0BIBnKl006940; Tue, 11 Jan 2011 19:11:49 +0100 In-Reply-To: <87zkr7nxo8.fsf@member.fsf.org> (Tassilo Horn's message of "Tue, 11 Jan 2011 18:43:35 +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.4-2.6 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:134450 Archived-At: Tassilo Horn writes: > joakim@verona.se writes: > >>> 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. > > Andreas already added DestroyMagickWand() calls that imply clearing, and > I locally added MagickWandTerminus() calls. Right now, I presume the > leak is not on the IM side. > > Your patch in the other mail (I'll try it later) seems to support that > guess. I've looked at this a little bit further. The error is that the image read with ReadImage is cloned by NewMagickWandFromImage not refered as I believed when I wrote the code. The code was written that way to avoid another memory problem I experienced with image bundles. If the current strategy remains, DestroyImage(im_image); should be the right fix. However, the strategy should probably be changed to avoid the cloning. This will result in a more complex code path. > >> 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? > > No, always. > >> - Only with PNG? Or also JPG? > > I tested with PNG and TIF, and both have the problem. > > Bye, > Tassilo -- Joakim Verona