Page 1 of 1

Imagemagick ignores all memory limits

Posted: 2015-12-22T14:49:34-07:00
by yanpas
I want to compress big pdf, here is what I enter:

Code: Select all

 parallel -P -1 convert {} -compress JPEG -quality 80 -resize 1100 -limit memory 128MiB -limit map 256Mib -limit area 256Mib compressed-{} ::: %N 
or the same

Code: Select all

convert in.pdf -compress JPEG -quality 80 -resize 1100 -limit memory 128MiB -limit map 256Mib -limit area 256Mib compressed-pdf.pdf 
.
And here is what is going on: first, ghostscript starts, it works for several minutes and consumes about 100MB of memory, then convert process starts and it eats 3 GB of mmory, it can eat even more, but I have to kill it. What am I doing wrong?

PDF consists of 300 pages and 150MB size. I have no idea why IM needs so much memory for 150mb pdf...

Version 6.7.7-10

Re: Imagemagick ignores all memory limits

Posted: 2015-12-22T16:00:49-07:00
by magick
Resource limits only apply to ImageMagick, not to any of the delegate programs or libraries (e.g. Ghostscript). Memory, map, and disk limits generally only apply to the ImageMagick pixel cache, although a few algorithms also checks memory and memory map limits before internal buffers are allocated (e.g. -despeckle). See http://www.imagemagick.org/script/archi ... .php#cache. For large PDF's, set your memory and map limits to 2GB and force the PDF pages to disk. Again, this limits memory consumption in ImageMagick, not Ghostscript, the required delegate library to interpret PDF pages.