Convert exceeds memory limit

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
sven
Posts: 27
Joined: 2003-10-02T02:21:38-07:00

Convert exceeds memory limit

Post by sven »

Hello magick,

when using the following command the memory consumption exceeds the given limit (300 MB and more are consumed):

Code: Select all

convert -limit memory 16 -limit map 16 -compress JPEG -quality 80 -density 152.4 -sample 50% D:\test1.tif D:\test1b.pdf
Version: ImageMagick 6.3.0 11/22/06 Q8 http://www.imagemagick.org


Is there a way to solve this issue?

Thanks a lot for your help.

Best regards
Sven
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

The memory/map limits only affect the image pixel cache. Other algorithms consume as much memory as required. We suspect the problem is that JPEG-compressed PDFs are generated as memory blobs. We can reduce memory consumption by performing the compression on disk. We'll get a patch into the next release of ImageMagick.
sven
Posts: 27
Joined: 2003-10-02T02:21:38-07:00

Post by sven »

Hello magick,

Thanks for your quick reply.

Is there any other chance to limit the memory usage of ImageMagick?
The problem is that conversions with huge images may lead to a crash of the system, because of a too high memory consumption.

Will your change also affect other programs like "compare"? That would be great.

Kind regards
Sven
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

No user program requesting memory should crash a system. That would be a bug in the operating system. For some algorithms, ImageMagick memory requirements are proportional to the area of the image. The only way around that is to identify which algorithm is consuming memory and avoid it or use some other program.
sven
Posts: 27
Joined: 2003-10-02T02:21:38-07:00

Post by sven »

magick wrote: The memory/map limits only affect the image pixel cache. Other algorithms consume as much memory as required. We suspect the problem is that JPEG-compressed PDFs are generated as memory blobs. We can reduce memory consumption by performing the compression on disk. We'll get a patch into the next release of ImageMagick.


Hi again,

has the patch already already been included into the most recent release of ImageMagick?

Best regards
Sven
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

The patch is available in ImageMagick 6.3.0-8 Beta. It will be released within a week or two.
sven
Posts: 27
Joined: 2003-10-02T02:21:38-07:00

Post by sven »

I've just installed the most recent version (6.3.1.0) of ImageMagick.

Can you tell me how to see, if the PDF JPEG compression consumes less memory than in earlier version? I don't see any differences...

Thanks a lot and best regards
Sven
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

Its possible something other than JPEG is consuming memory. Embedded JPEG within PDF is written to disk in ImageMagick 6.3.1 rather than a memory blob (see JPEGEncodeImage()). You also need to set the memory limit to something small to turn off JPEG optimization which is memory intensive (e.g. -limit memory 1).
Post Reply