convert: memory allocation failed

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
menteith
Posts: 10
Joined: 2015-03-30T14:49:19-07:00
Authentication code: 6789

convert: memory allocation failed

Post by menteith » 2016-08-12T08:22:54-07:00

Hi all,

I have encountered the "memory allocation failed" problem. I'm trying to convert a 472MB folder with TIFFs to a PDF file.

I use current version of IM, specifically ImageMagick-7.0.2-7-Q8-x86-dll.exe on Windows 10. My GhostScript is also current, that is, Ghostscript 9.19 (2016-03-23). To be sure that everything is OK, I unistalled IM and GS and installed once again GS and IM (in this order).

My command line is:

Code: Select all

convert input\*.tif -compress Group4 -quality 100 output.pdf
I also tried

Code: Select all

convert input\*.tif -compress Group4 -quality 100 -limit memory 128mb output.pdf
Each time I get

Code: Select all

convert: memory allocation failed
When I tried to convert a smaller folder (178 MB) of TIFFs everything went OK.

Files to converted are available at http://www23.zippyshare.com/v/FCrO6r7G/file.html (22MB)

Thanks in advance!

snibgo
Posts: 12029
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert: memory allocation failed

Post by snibgo » 2016-08-12T08:52:28-07:00

The size in bytes of the TIFFs is irrelevant. How many TIFF files? How many pixels per TIFF? Are they colour or grayscale?

How much memory on your computer? What operating system? (Windows?)

It might be helpful if you gave the exact error message. Although it should put pixel caches on disk if there's not enough memory, it allocates smaller structures in memory, and gives up if there isn't enough free memory.

As a workaround, you might try compressing each TIFF as Group4 (in separate commands) before combining all these into a single PDF.
snibgo's IM pages: im.snibgo.com

menteith
Posts: 10
Joined: 2015-03-30T14:49:19-07:00
Authentication code: 6789

Re: convert: memory allocation failed

Post by menteith » 2016-08-12T08:58:50-07:00

Thanks for your quick response.

I have 75 files. All of them have 800 DPI and they are gray.

Code: Select all

identify 114_1L.tif
114_1L.tif TIFF 4209x6022 4209x6022+0+0 1-bit Bilevel Gray 3.174MB 0.000u 0:00.000
I use Windows 10 x86. I have 4GB RAM.

snibgo
Posts: 12029
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert: memory allocation failed

Post by snibgo » 2016-08-12T09:17:07-07:00

4209*6022*75 = 1.9 G pixels. In v6, Q16, these would need 8 bytes/pixel, so 16 GB. V7 needs (I think) only 2 bytes/pixel for grayscale, but that is 4 GB. So you run out of memory. If pixels won't fit in memory, they should be put to disk. In your case, you may have used all the memory with pixels, then tried to allocate something else.

To force more pixels to disk, edit policy.xml. I think you should uncomment "memory" and "map" and set them to 1GiB or 500MiB or whatever.
snibgo's IM pages: im.snibgo.com

menteith
Posts: 10
Joined: 2015-03-30T14:49:19-07:00
Authentication code: 6789

Re: convert: memory allocation failed

Post by menteith » 2016-08-12T09:50:28-07:00

Setting 1GB didn't work but 500 did. Thanks!

Post Reply