Many files created in /tmp

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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

ImageMagick caches image pixels to disk if the image you are working with is large. When ImageMagick exits it should clean-up any temporary files it creates. If the ImageMagick process fails with a signal it cannot catch, the temporary files remain behind, however, they can safely be removed after the process completes. ImageMagick temporary files, as you surmised, always start with the magick- prefix.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

On our server, ImageMagick creates a lot of such temporary files that remains behind, with a size of 0 bytes. The ImgeMagick library (called through a C++ interface) sreturns properly each time, so we should not see this files remaining.

Agreed. What version of ImageMagick are you using? See if the problem persists with the latest ImageMagick release 6.2.6-4.
Sometimes, when we have to kill the process, some temporary files remains with a non-null size. These files have usually a size near 5 giga bytes. We don't process images that should need such a large amount of memory. Do you have an explaination for this?

You can reduce resource requirements by using the Q8 version of ImageMagick rather than Q16, however, Q8 scales any 16-bit images you process to 8-bits. Otherwise, if 5 GB temporary files are created it generally means you can processing a large image (i.e. a 32000 x 32000 16-bit image).
I have found somewhere on this forum that the images larger than 65535 pixels are cached on disk. Do you comfirm this? Is there a way to change this parameters?

Images cached to memory, memory-mapped, or on disk are determined by the resource limits. Type
  • identify -list resource
to find out your limits. You can modify these by setting the environment variables MAGICK_MEMORY_LIMIT, MAGICK_MAP_LIMIT, etc. or by calling MagickLib::SetMagickResourceLimit().
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

We have not experienced left-over temporary files so currently we have no suggestions why they remain. You could always set the environment variable MAGICK_DEBUG to all or trace to debug the situation.

The area limit means if any one image exceeds this limit, it is automatically cached to disk. This helps prevent one large image from consuming all your memory.

If the memory limit is exceeded the pixels are cached to disk but they memory-mapped which is generally faster than read/writing directly to disk. If the memory-mapped limit is exceeded the pixels are cached directly to disk. If the disk limit is exceeded the program halts.
Post Reply