Page 1 of 1
Memory leak after multiple mogrify
Posted: 2016-01-28T07:42:22-07:00
by BobTateson
I am using mogrify to process batches of 1365 .svg files into .bmp. After mogrify has finished there is 2.9 Mb less free Ram. (as seen in HTOP) This would not be a great problem except I am repeating the process hundreds of times as part of a shell script. I want to stress that the problem is what happens after mogrify closes, not while it is working (I solved that problem by switching from convert to mogrify).
I cannot reclaim this memory by stopping the scrip, closing the shell it is running in, deleting the svg or the bmp files, or the folder they are in. The only way I can reclaim this memory is by rebooting the computer. It looks as though it is allocated by mogrify every time it starts work but not freed after it closes.
I am using Linux Mint 17.2 Cinnamon on a ThinkPad T400 with 2Gb RAM.
The following line is in a shell script looping about once every minute. The batch mogrify takes about 45s of this.
mogrify -format bmp -compress none +matte s????.svg
Re: Memory leak after multiple mogrify
Posted: 2016-01-28T07:43:27-07:00
by dlemstra
And you are using the latest version of ImageMagick?
Re: Memory leak after multiple mogrify
Posted: 2016-01-28T07:53:49-07:00
by BobTateson
Yes sorry I didnt say Imagemagick 6.7.7
Re: Memory leak after multiple mogrify
Posted: 2016-01-28T13:06:02-07:00
by dlemstra
That version is ancient and we did fix a couple of memory leaks since that version. Could you give it a try with the latest version of ImageMagick?
Re: Memory leak after multiple mogrify
Posted: 2016-01-28T14:24:19-07:00
by BobTateson
imagemagick 8:6.7.7.10-6ubuntu3
2014/03/06
is what is in the ubuntu repositary - thats what I have installed
what is the latest version?
Re: Memory leak after multiple mogrify
Posted: 2016-01-28T14:34:33-07:00
by fmw42
Latest IM version is 6.9.3.2. Yours is over 150 versions old.
Re: Memory leak after multiple mogrify
Posted: 2016-01-28T15:27:23-07:00
by BobTateson
I managed to compile and install from the source
ImageMagick 6.9.3-2 Q16 x86_64 2016-01-28
Thought I was doing well. But tried it out to display a jpg and got
display: no decode delegate for this image format `JPEG' @ error/constitute.c/ReadImage/501.
This is obviously some kind of installation problem. Oh dear. I think I'll just go to bed.
Thanks for your help.
Re: Memory leak after multiple mogrify
Posted: 2016-01-28T15:51:50-07:00
by fmw42
When installing from source, you must install all the needed delegates before compiling Imagemagick. If they are already installed, then you must point Imagemagick to where you have the delegates (such as JPG, PNG, TIFF, Ghostscript, fontconfig, freetype, etc).
see CPPFLAGS and LDFLAGS at
http://www.imagemagick.org/script/advan ... #configure
Re: Memory leak after multiple mogrify
Posted: 2016-01-29T00:48:35-07:00
by BobTateson
I have tried playing with the config but it's not installing everything. Sorry guys I think I am out of my depth here. I really don't know how to set the config options. And I don't expect you to waste your time teaching me. I will just have to live with the memory leaks on 6.7.7. and wait for the ubuntu repositary to hold the latest version of imagemagic. Thanks for your help anyway.
Re: Memory leak after multiple mogrify
Posted: 2016-01-29T09:14:12-07:00
by BobTateson
I will have a go at installing 6.9. from source. I assume that if I am running 6.6 these 'delegates' are somewhere on my computer at the moment. What are they called? I only need the one for .svg and .bmp. If I know their names I can Find them and give the path to configure. Is that right?
Re: Memory leak after multiple mogrify
Posted: 2016-01-29T11:04:26-07:00
by fmw42
both are built in -- no delegates that I know. For SVG, IM has an internal MSVG (XML), but you can install RSVG for better results. I do not know much about .bmp, but I have never installed any delegate for it, though it may need a subordinate delegate or come with some other delegate. Sorry, I do not know much about Linux.
Re: Memory leak after multiple mogrify
Posted: 2016-01-30T00:34:53-07:00
by snibgo
For BMP, ImageMagick seems to contain the code to read/write, in coders\bmp.c.
For SVG, IM also contains code, in coders\svg.c. However, Inkscape is a more complete implementation. IM doesn't need special compilation to delegate reading to Inkscape. If Inkscape is in the system path at runtime, IM will find it and use it.
Re: Memory leak after multiple mogrify
Posted: 2016-01-30T03:40:57-07:00
by BobTateson
Thanks for your help and suggestions. I have decided to give up trying to install imagemagick 6.9 from source.
As all I want to do is render large batches of .svg files into some bitmap form, I am going to investigate cairo. After all imagemagic uses cairo but is (for my needs) burdened with a vast amount of other functionality.
In the meantime I will continue to use mogrify from imagemagick 6.6. I have found a crude fix for the memory loss problem. When free memory is getting short, I force the computer into hibernate mode and then immediately wake it up. This reallocates all the RAM and frees up what was lost by imagemagic.
So thanks again guys.
Re: Memory leak after multiple mogrify
Posted: 2016-01-30T03:51:55-07:00
by snibgo
BobTateson wrote:As all I want to do is render large batches of .svg files into some bitmap form ...
If that's all you want to do, I suggest you look at Inkscape.
Re: Memory leak after multiple mogrify
Posted: 2016-01-30T04:28:30-07:00
by BobTateson
Good idea! I have just looked at inkscape and it has command line processing. That could well be a better bet than imagemagick. I will investigate further. Thanks.