Page 1 of 3
IM hangs
Posted: 2010-06-30T16:27:13-07:00
by gregory
Hi,
I have a web service which creates animated images using ImageMagick.
IM uses "convert" to make an animations but sometimes "convert" freezes in a loop and starts using cpu/memory in big amounts until servers stops responding at all.
It happends once a week. Maybe twice. I can't still find out the reason why it happends. I think somebody upload very big images so IM tries to make an animations from a batch of a big images.
Is there any way to kill this proccess automatically while server is answering? Maybe any IM timeout options or a script which monitores these situations?
I use IM 6.6.0-9 and CentOS.
Re: IM freezes
Posted: 2010-06-30T16:34:43-07:00
by fmw42
If you are sure it is due to large images, you can just check the image file size and quit if too large. Also you can do some special large image processing to speed things up so that you are not thrashing. I am not an expert on this, but see
http://www.imagemagick.org/Usage/files/#massive
Other than this, you need help from someone more knowledgeable than me.
Re: IM freezes
Posted: 2010-06-30T16:38:24-07:00
by gregory
I'm not sure it's due to large images... that's why I want to find a way to monitor this problem and find out why IM freezes. But the problem exists so I need to solve it somehow... Is there any "timeout" options for convert program?
Re: IM hangs
Posted: 2010-06-30T17:36:45-07:00
by fmw42
sorry, not that I know about.
But see -debug at
http://www.imagemagick.org/Usage/basics/#controls. You could add that to your command and see if it returns something that you could report back here to the IM developers.
Re: IM hangs
Posted: 2010-06-30T18:23:12-07:00
by snibgo
You can limit various resource, including time:
convert -limit time 1 in.jp2 out.jpg
This will actually allow more than one second. Perhaps it doesn't check very often.
Re: IM hangs
Posted: 2010-06-30T18:42:32-07:00
by fmw42
Re: IM hangs
Posted: 2010-07-01T05:59:44-07:00
by gregory
There are no info about "-limit time" at your link. Do you have a documentation with examples of it? Or maybe something about using MAGICK_TIME_LIMIT?
Re: IM hangs
Posted: 2010-07-01T09:15:22-07:00
by fmw42
sorry I have never used it. I was just pointing out where there was some information. you probably need help from someone more expert in coding than I.
Re: IM hangs
Posted: 2010-07-01T10:52:10-07:00
by gregory
Does anybody else know anything about "-limit time" OR "MAGICK_TIME_LIMIT" options?
Re: IM hangs
Posted: 2010-07-01T11:43:21-07:00
by gregory
Maybe someone can give an advice where I can find an IM coding experts?
http://www.imagemagick.org/script/resources.php I see there an environment variables (MAGICK_TIME_LIMIT) but I don't know where I can define this variable and set the time limits.
Re: IM hangs
Posted: 2010-07-01T12:09:41-07:00
by magick
You can set system wide limits in your policy.xml configuration file. Take a look:
Code: Select all
<!--
Configure ImageMagick policies.
Domains include system, delegate, coder, filter, path, or resource.
Rights include none, read, write, and execute. Use | to combine them,
for example: "read | write" to permit read from, or write to, a path.
Use a glob expression as a pattern.
Suppose we do not want users to process MPEG video images:
<policy domain="delegate" rights="none" pattern="mpeg:decode" />
Here we do not want users reading images from HTTP:
<policy domain="coder" rights="none" pattern="HTTP" />
Lets prevent users from executing any image filters:
<policy domain="filter" rights="none" pattern="*" />
The /repository file system is restricted to read only. We use a glob
expression to match all paths that start with /repository:
<policy domain="path" rights="read" pattern="/repository/*" />
Any large image is cached to disk rather than memory:
<policy domain="resource" name="area" value="1gb"/>
-->
<policymap>
<!-- <policy domain="system" name="precision" value="6"/> -->
<!-- <policy domain="resource" name="temporary-path" value="/tmp"/> -->
<!-- <policy domain="resource" name="memory" value="2gb"/> -->
<!-- <policy domain="resource" name="map" value="4gb"/> -->
<!-- <policy domain="resource" name="area" value="1gb"/> -->
<!-- <policy domain="resource" name="disk" value="16eb"/> -->
<!-- <policy domain="resource" name="file" value="768"/> -->
<!-- <policy domain="resource" name="thread" value="8"/> -->
<!-- <policy domain="resource" name="time" value="3600"/> -->
</policymap>
Look at the policy.xml discussion here:
http://www.imagemagick.org/script/resources.php. Also look at the Cache Storage and Resource Requirements of
http://www.imagemagick.org/script/archi ... .php#cache:
As an example, our online web interface to ImageMagick, ImageMagick Studio, has an area limit of 64 megabytes, a memory limit of 128 mebibytes and a map limit of 256 mebibytes and a disk limit of 1 gigabytes. Since we process multiple simultaneous sessions, we don't want any one session consuming all the available memory. Instead large images are cached to disk. If the image is too large and exceeds the pixel cache disk limit, the program exits. In addition, we place a 60 second time limit to prevent any run-away processing tasks.
Re: IM hangs
Posted: 2010-07-01T12:12:43-07:00
by gregory
I tried to use "-limit time 1" but convert tool doesn't seems to exit properly:
Code: Select all
[root@server ___]# convert -limit time 1 beefee_smile.jpg -resize 200 1.jpg
convert: time limit exceeded `(ݞM=▒$▒dH▒▒8▒▒ҭB@▒▒▒[5t▒f^▒β▒C▒B▒▒T
' @ fatal/cache.c/GetImagePixelCache/2180.
PuTTYPuTTY
Also convert proccess still uses memory and presents in a "ps ax" after this exit.
Re: IM hangs
Posted: 2010-07-01T12:18:36-07:00
by magick
Time limit exceeded is a fatal error. The process exits immediately with a non-zero exit status.
Re: IM hangs
Posted: 2010-07-01T12:21:35-07:00
by gregory
Yes, but this proccess still exists in system even after this fatal error:
Code: Select all
[root@server ~]# ps ax | grep convert
22642 pts/1 S+ 0:00 convert -limit time 1 beefee_smile.jpg -resize 200 1.jpg
Re: IM hangs
Posted: 2010-07-01T12:23:27-07:00
by gregory
Code: Select all
[root@server ~]# ps aux | grep convert
root 22642 0.2 1.9 115420 40804 pts/1 S+ 14:20 0:00 convert -limit time 1 beefee_smile.jpg -resize 200 1.jpg