I'm running a web app that uses ImageMagick to convert PDFs to PNG.
Some weeks ago it started filling the server's HDD, because it stopped deleting the temp files (/tmp/magick-*). We solved that by using a job to clean old temporary files. This started to happen after we changed from converting PDFs to JPGs to PDFs to PNGs (We needed to keep some transparecy).
In the last few days, we started to see this error in the app's log:
FailedToExecuteCommand `"gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r300x300" "-sOutputFile=/tmp/magick-1608EvBhAQ3mK7Lu%d" "-f/tmp/magick-1608aLLJuet4cK9S" "-f/tmp/magick-1608QFcecyiIbnxh"' (-1) @ error/delegate.c/ExternalDelegateCommand/461
I thought that it was a side effect of updating the kernel. Maybe something broke when changing from kernel 3.* to 4.*. So we migrated the web app to a fresh install in a new server, but the error keep appearing.
The question is, how can I be sure that the root of the problem is that the server runs out of memory? Which log should I read and what should I look for in them?
Here is a portion of the code that makes the web app to fail:
with Image(filename=pdf_name, resolution=300) as img:
...
img.crop(left=xi, top=yi, right=xf, bottom=yf)
img.background_color = Color('white')
img.alpha_channel = 'remove'
...
img.save(filename=img_name)
Thanks
EDIT:
A strange thing I noticed is that once the error pop ups for a convert, then all subsequent converts fail until I restart the server. It's like something is hanging.