Details about resources management
Posted: 2013-07-01T01:57:52-07:00
I need to process 200 images (from a PDF) at once, but avoiding much disk work derived from RAM exhaustion.
Previous status:
The following are the commands executed in a script:
I've tried a lot of combinations for memory, map and disk limits, but in all cases ImageMagick breaks with a "Segmentation fault". Monitorizing resources usage, I see that the process works during 30 seconds normally (using few memory), and in the next 5 seconds eats all memory available and breaks. This last test was deactivating swap, to avoid waiting minutes or hours before failure.
I've read the details described at:
http://www.imagemagick.org/script/architecture.php
http://www.imagemagick.org/script/resources.php
But I have some questions not cleared in the documentation:
Previous status:
Code: Select all
$ convert --version
Version: ImageMagick 6.6.9-7 2012-08-17 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP
$ free -m
total used free shared buffers cached
Mem: 12000 4342 7658 0 310 2396
-/+ buffers/cache: 1635 10365
Swap: 4095 0 4095
$ identify -list resource
File Area Memory Map Disk Thread Time
-------------------------------------------------------------------------------
768 3.1458GB 11.719GiB 23.438GiB unlimited 4 unlimited
Code: Select all
export MAGICK_MEMORY_LIMIT=6631080
export MAGICK_MAP_LIMIT=6631080
export MAGICK_DISK_LIMIT=1105180
export MAGICK_FILE_LIMIT=10
mkdir 00pages
gs -sDEVICE=png16m -r300 -dNOPAUSE -dQUIET -dBATCH "-sOutputFile=./00pages/pag-%04d.png" "book1.pdf"
mkdir 01contrast
convert "./00pages/*.png" -quality 40 -brightness-contrast -33x40 "./01contrast/pag-%04d.png"
I've read the details described at:
http://www.imagemagick.org/script/architecture.php
http://www.imagemagick.org/script/resources.php
But I have some questions not cleared in the documentation:
- When ImageMagick is called to process several files (with wildcards), does it process one by one, or all at once? If it's all at once, how can I order to process in smaller series?
- Can I specify all limits in bytes every time (memory, map, disk)?
- The order of resource usage is: memory -> map (areas) -> disk (files). Am I right? If is there enough memory, I suppose map and disk aren't used; right?
- Is the "pixel cache memory" a kind of disk cache for "pixel cache files"?
- If I get a page (DIN-A4, 300ppi, 24bpp) I calculate that its binary size is 25MiB. Is this the necessary area for this single image?
- Does ImageMagick need the possibility to open one pixel cache file per image, or more than one?
- I understand memory variables for main working area, and map variables for a subsidiary area. Do have them any relation with using or not using system's swap memory? How can I equilibrate the numbers to maximize performance and avoid disk?