ImageMagick Memory Usage Limit

Basically, I try to save memory on my Nginx server under a certain amount, because I'm crazy (according to my friends), and I want to save some money. However, I'm worried that ImageMagick might push it around the edge.

I use -limit area 20MiB , and I also tried -limit memory 15MiB -limit map 15MiB , but when checking the process (as it starts) through top -c (with Shift-M) and ps aux it shows it, sometimes significantly great memory, to the limit. To give numbers, it can use 35 MB or 40 MB, instead of 20 MB / 30 MB I would expect. I would not be worried about 2 MB or 3 MB, but this is a pretty big bias.

I was told that additional memory may be the ImageMagick overhead when loading the interpreter, etc., but I am not very familiar with Unix programs, so I don’t know what is in this section.

If anyone can explain why this is happening, that would be great. If this is a normal thing, great. I'm just adjusting things to take into account the fact that it can use my limit plus a certain amount, but if it is not, and the -limit parameter -limit not limit memory for a certain amount, then what exactly is the point that this parameter is in ImageMagick?

Thanks again for your help in advance, it is very much appreciated, as always.

+7
source share
2 answers

According to the documentation, ImageMagick moves all memory operations to mmaped files, so it will start replacing if you have enough disk space, see the manual: SNIP from the -limit manual :

The value for the File is the number of files. The disk limit is in Gigabutes and the values ​​for other resources are in megabytes. From the default 768 files, 1024 MB of memory, 4096 MB of card and unlimited disk are limited, but they are adjusted during startup on platforms that can provide information about available resources. When the limit is reached, ImageMagick will fail in some way or compensating action, if possible. For example, -limit memory 32 -limit card 64 limits memory When a pixel cache reaches the memory limit, it uses memory mapping. When this limit is reached, it goes to disk. If the drive has a hard limit, the program does not work.

+2
source

Limitations affect only the ImageMagick pixel cache. The program code and everything that libraries / delegates can do to upload or process images does not depend on these settings at all.

You do not indicate what you are looking at from above; the corresponding column will obviously be RES or RSIZE. With such small limits as 20MiB, the program and library code will represent a significant fraction of the resident specified size.

To verify that you are using the correct units for environment variables, use identify -list resource . If the size of the memory pixel cache (MAGICK_MEMORY_LIMIT) is insufficient for the image, the mmap-ed file (MAGICK_MAP_LIMIT) will be used, and if this limit is too low, a regular disk file (MAGICK_DISK_LIMIT) will be used instead. If all restrictions are too low, ImageMagick will immediately fail with an error such as cache resources exhausted , Memory allocation failed or corrupt image .

+2
source

All Articles