convert: Memory allocation failed `Cannot allocate memory'

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
Jogesh Anand
Posts: 4
Joined: 2010-08-27T05:27:47-07:00
Authentication code: 8675308

convert: Memory allocation failed `Cannot allocate memory'

Post by Jogesh Anand »

Hi Magick,

I am getting the following error while processing .psd files of large size approx 7MB.
convert: Memory allocation failed `Cannot allocate memory'
convert: Memory allocation failed `Cannot allocate memory'.


The .psd file can be downloaded from the below mentioned location
http://www.mediafire.com/?6tmdj93u54qu8l4

The command which i am using for converting the file is a two way process.
step1 : convert-define jpeg:size=50x50 filename.psd -thumbnail '50x50>' -background gray75 -gravity center -extent 50x50 -strip intermediateFilename.gif
Step2: convert intermediateFilename.gif -matte -virtual-pixel transparent -channel A -blur 0x4 -threshold 50% +channel finalimage.gif

i have set the environment variable
export MAGICK_TEMPORARY_PATH="$MAGICK_TEMPORARY_PATH:/apps/tmp" because the temporary folder does not have enough memory space

when i run the df space is shows:
/dev/mapper/rootvg-homelv
4128448 2388092 1530644 61% /home
/dev/mapper/rootvg-optlv
4128448 166128 3752608 5% /opt
/dev/mapper/rootvg-tmplv
2064208 549816 1409536 29% /tmp
/dev/mapper/rootvg-usrlv
6192704 1771256 4106876 31% /usr
/dev/mapper/rootvg-varlv
5465704 297956 4890060 6% /var
/dev/mapper/appsvg-appslv
309637120 208267928 85640552 71% /apps

So i guess it has enough memory space in the /apps folder but still i am getting cannot allocate memory. Does it have to with the RAM on my server. let me know how i can resolve this critical issue. Any help will be appreciated.

I will also post my comments if the error is resolved so that it will be useful for others who get similar errors.

Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert: Memory allocation failed `Cannot allocate memor

Post by fmw42 »

Probably you are out of RAM. See http://www.imagemagick.org/Usage/files/#massive
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: convert: Memory allocation failed `Cannot allocate memor

Post by el_supremo »

Which version of ImageMagick are you using and how much ram do you have?
I ran your command on Windows 7 Pro and it completed without any trouble although the output gif file doesn't look very useful. The windows resource monitor said that the maximum ram used was about 90 MB.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
Jogesh Anand
Posts: 4
Joined: 2010-08-27T05:27:47-07:00
Authentication code: 8675308

Re: convert: Memory allocation failed `Cannot allocate memor

Post by Jogesh Anand »

Hi,

My version of IM is :
Version: ImageMagick 6.4.3 2009-07-03 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2008 ImageMagick Studio LLC

On using a top command i get :
top - 02:31:22 up 9 days, 5:42, 1 user, load average: 0.00, 0.00, 0.00
Tasks: 122 total, 1 running, 118 sleeping, 2 stopped, 1 zombie
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 2056888k total, 1997548k used, 59340k free, 452128k buffers
Swap: 4194296k total, 35316k used, 4158980k free, 771604k cached

Do i have insufficient RAM memory on my server ? I also need to process .psd files which are of 800MB in size. What do i require to process? Even 7MB files are giving that error. Do i have to clear the any temporary files formed during processing so that i get enough memory space for processing files again ? Also let me know how much RAM would i need ? Pour in your thoughts.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: convert: Memory allocation failed `Cannot allocate memor

Post by magick »

You may need to upgrade. We successfully converted your image with ImageMagick 6.6.8-5.
Jogesh Anand
Posts: 4
Joined: 2010-08-27T05:27:47-07:00
Authentication code: 8675308

Re: convert: Memory allocation failed `Cannot allocate memor

Post by Jogesh Anand »

Hi

Thanks Magick. I have searched Image Magick forums on the the same issue. I got the -debug "all" option through which i tried to debug. Putting the stack trace here.

image contains 149 layers
2011-03-25T10:32:11-04:00 0:01 0.020u 6.4.3 Coder convert[1124]: psd.c/unknown/850/Coder
reading layer #1
2011-03-25T10:32:11-04:00 0:01 0.020u 6.4.3 Coder convert[1124]: psd.c/unknown/860/Coder
offset(4294967250,4294967234), size(-4294966472,-4294966698), channels=5
2011-03-25T10:32:11-04:00 0:01 0.020u 6.4.3 Coder convert[1124]: psd.c/unknown/870/Coder
channel[0]: type=-1, size=16485
2011-03-25T10:32:11-04:00 0:01 0.020u 6.4.3 Coder convert[1124]: psd.c/unknown/870/Coder
channel[1]: type=0, size=402525
2011-03-25T10:32:11-04:00 0:01 0.020u 6.4.3 Coder convert[1124]: psd.c/unknown/870/Coder
channel[2]: type=1, size=405682
2011-03-25T10:32:11-04:00 0:01 0.020u 6.4.3 Coder convert[1124]: psd.c/unknown/870/Coder
channel[3]: type=2, size=413603
2011-03-25T10:32:11-04:00 0:01 0.020u 6.4.3 Coder convert[1124]: psd.c/unknown/870/Coder
channel[4]: type=3, size=301565
2011-03-25T10:32:11-04:00 0:01 0.020u 6.4.3 Coder convert[1124]: psd.c/unknown/890/Coder
blend=norm, opacity=0, clipping=false, flags=8, visible=true
2011-03-25T10:32:11-04:00 0:01 0.020u 6.4.3 Coder convert[1124]: psd.c/unknown/901/Coder
layer contains additional info
2011-03-25T10:32:11-04:00 0:01 0.020u 6.4.3 Coder convert[1124]: psd.c/unknown/935/Coder
layer blending ranges: length=40
2011-03-25T10:32:11-04:00 0:01 0.020u 6.4.3 Coder convert[1124]: psd.c/unknown/945/Coder
source(ffff), dest(ffff)
2011-03-25T10:32:11-04:00 0:01 0.020u 6.4.3 Coder convert[1124]: psd.c/unknown/945/Coder
source(ffff), dest(ffff)
2011-03-25T10:32:11-04:00 0:01 0.020u 6.4.3 Coder convert[1124]: psd.c/unknown/945/Coder
source(ffff), dest(ffff)
2011-03-25T10:32:11-04:00 0:01 0.020u 6.4.3 Coder convert[1124]: psd.c/unknown/945/Coder
source(ffff), dest(ffff)
2011-03-25T10:32:11-04:00 0:01 0.020u 6.4.3 Coder convert[1124]: psd.c/unknown/945/Coder
source(ffff), dest(ffff)
2011-03-25T10:32:11-04:00 0:01 0.020u 6.4.3 Coder convert[1124]: psd.c/unknown/961/Coder
layer name: Background
2011-03-25T10:32:11-04:00 0:01 0.020u 6.4.3 Coder convert[1124]: psd.c/unknown/1018/Coder
unsupported data: length=249
2011-03-25T10:32:11-04:00 0:01 0.020u 6.4.3 Exception convert[1124]: cache.c/unknown/3509/Exception
Pixel cache allocation failed `Krushers_TentCard_01.psd'
2011-03-25T10:32:11-04:00 0:01 0.030u 6.4.3 Exception convert[1124]: cache.c/unknown/3509/Exception
Pixel cache allocation failed `Krushers_TentCard_01.psd'
2011-03-25T10:32:11-04:00 0:01 0.030u 6.4.3 Exception convert[1124]: cache.c/unknown/1226/Exception
Memory allocation failed `Cannot allocate memory'
convert: Memory allocation failed `Cannot allocate memory'.

When i do a convert -list resource

File Area Memory Map Disk
----------------------------------------------------------------
768 3.9232gb 2.9424gb 7.8464gb 16tb

The -limit memory or -limit map or -limit disk does not seem to show any difference on the error. Isn't Image Magick able to allocate the Pixel cache to disk if there is not enough space ? let me know what u think
Post Reply