Memory allocation failure on Windows when generating GIFs
Posted: 2013-11-14T12:03:54-07:00
Main OS: Windows 7 with 8GB of memory
Virtual OS: Debian with 384MB of memory
Versions tried (on Windows):
- ImageMagick-6.8.7-5-Q16-x86-dll.exe
- ImageMagick-6.8.7-5-Q8-x86-dll.exe
- ImageMagick-6.8.7-5-Q16-x64-dll.exe
Output from identify -list resource (on Windows):
Versions tried (on virtual Debian):
- Version: ImageMagick 6.6.0-4 2012-05-02 Q16
Output from identify -list resource (on virtual Debian):
I use the following script on Windows to generate GIFs from PNG files:
Problem is, sometimes it works, sometimes it gives a lot of "memory allocation failed" errors or ImageMagick crashes resulting in incomplete GIFs. There seems to be no pattern to it; it may fail on very small gifs (small and few images) and succeed on large gifs (large and many images), but if it fails on certain images, it will keep failing for those even after a reboot, even though sometimes one of the commands that failed may succeed, while a command that completed will now fail. It's random is what I'm saying.
But! Those commands will still succeed on the virtual Debian OS with 384MB of memory for those images that fail on Windows.
So, how is this possible? How can I run out of memory on my main OS when it works on the virtual OS? What's causing it and how can I fix it? Thanks.
By the way, I have seen this: http://imagemagick.sourceforge.net/http/www/FAQ.html#C9, and there is zero possibility that I'm running out of memory when there's only about 30 images of size 250x184 which even with the highest Quantum depth should give about 920000 bytes required for one image which is what, 27.6MB for the whole GIF.
Virtual OS: Debian with 384MB of memory
Versions tried (on Windows):
- ImageMagick-6.8.7-5-Q16-x86-dll.exe
- ImageMagick-6.8.7-5-Q8-x86-dll.exe
- ImageMagick-6.8.7-5-Q16-x64-dll.exe
Output from identify -list resource (on Windows):
Code: Select all
File Area Memory Map Disk Thread Throttle Time
--------------------------------------------------------------------------------
1536 8.4068GB 3.9147GiB 7.8294GiB unlimited 4 0 unlimited
- Version: ImageMagick 6.6.0-4 2012-05-02 Q16
Output from identify -list resource (on virtual Debian):
Code: Select all
File Area Memory Map Disk Thread Time
-------------------------------------------------------------------------------
768 777.8MB 556.3MiB 1.4488GiB 18.446744EB 1 unlimited
Code: Select all
@ECHO OFF
SETLOCAL
SET OutputName=%1
SET delay=%2
SET ImgMagConvert="C:\Program Files (x86)\ImageMagick-6.8.7-Q8"
IF "%1"=="" SET OutputName=.
IF "%2"=="" SET delay=4
IF NOT EXIST "%OutputName%" (
MKDIR "%OutputName%"
)
@ECHO ON
%ImgMagConvert%\convert +repage -fuzz 0.0%% -delay %delay% -loop 0 frames/*.png -layers OptimizePlus -layers OptimizeTransparency "%OutputName%\Almost-00.gif"
%ImgMagConvert%\convert +repage -fuzz 0.5%% -delay %delay% -loop 0 frames/*.png -layers OptimizePlus -layers OptimizeTransparency "%OutputName%\Almost-05.gif"
%ImgMagConvert%\convert +repage -fuzz 1.0%% -delay %delay% -loop 0 frames/*.png -layers OptimizePlus -layers OptimizeTransparency "%OutputName%\Almost-10.gif"
%ImgMagConvert%\convert +repage -fuzz 1.5%% -delay %delay% -loop 0 frames/*.png -layers OptimizePlus -layers OptimizeTransparency "%OutputName%\Almost-15.gif"
%ImgMagConvert%\convert +repage -fuzz 2.0%% -delay %delay% -loop 0 frames/*.png -layers OptimizePlus -layers OptimizeTransparency "%OutputName%\Almost-20.gif"
%ImgMagConvert%\convert +repage -fuzz 2.5%% -delay %delay% -loop 0 frames/*.png -layers OptimizePlus -layers OptimizeTransparency "%OutputName%\Almost-25.gif"
%ImgMagConvert%\convert +repage -fuzz 3.0%% -delay %delay% -loop 0 frames/*.png -layers OptimizePlus -layers OptimizeTransparency "%OutputName%\Almost-30.gif"
gifsicle -O3 --colors 128 "%OutputName%\Almost-00.gif" >"%OutputName%\%OutputName%-00-128.gif"
gifsicle -O3 --colors 256 "%OutputName%\Almost-00.gif" >"%OutputName%\%OutputName%-00-256.gif"
gifsicle -O3 --colors 128 "%OutputName%\Almost-05.gif" >"%OutputName%\%OutputName%-05-128.gif"
gifsicle -O3 --colors 256 "%OutputName%\Almost-05.gif" >"%OutputName%\%OutputName%-05-256.gif"
gifsicle -O3 --colors 128 "%OutputName%\Almost-10.gif" >"%OutputName%\%OutputName%-10-128.gif"
gifsicle -O3 --colors 256 "%OutputName%\Almost-10.gif" >"%OutputName%\%OutputName%-10-256.gif"
gifsicle -O3 --colors 128 "%OutputName%\Almost-15.gif" >"%OutputName%\%OutputName%-15-128.gif"
gifsicle -O3 --colors 256 "%OutputName%\Almost-15.gif" >"%OutputName%\%OutputName%-15-256.gif"
gifsicle -O3 --colors 128 "%OutputName%\Almost-20.gif" >"%OutputName%\%OutputName%-20-128.gif"
gifsicle -O3 --colors 256 "%OutputName%\Almost-20.gif" >"%OutputName%\%OutputName%-20-256.gif"
gifsicle -O3 --colors 128 "%OutputName%\Almost-25.gif" >"%OutputName%\%OutputName%-25-128.gif"
gifsicle -O3 --colors 256 "%OutputName%\Almost-25.gif" >"%OutputName%\%OutputName%-25-256.gif"
gifsicle -O3 --colors 128 "%OutputName%\Almost-30.gif" >"%OutputName%\%OutputName%-30-128.gif"
gifsicle -O3 --colors 256 "%OutputName%\Almost-30.gif" >"%OutputName%\%OutputName%-30-256.gif"
@ENDLOCAL
But! Those commands will still succeed on the virtual Debian OS with 384MB of memory for those images that fail on Windows.
So, how is this possible? How can I run out of memory on my main OS when it works on the virtual OS? What's causing it and how can I fix it? Thanks.
By the way, I have seen this: http://imagemagick.sourceforge.net/http/www/FAQ.html#C9, and there is zero possibility that I'm running out of memory when there's only about 30 images of size 250x184 which even with the highest Quantum depth should give about 920000 bytes required for one image which is what, 27.6MB for the whole GIF.