Page 1 of 1

tons of magick-XXXX files in C:\Documents and Settings

Posted: 2006-06-26T05:01:24-07:00
by swiss_knife
I am doing some memory tests with Magick, and I am getting tons of files like:

C:\Documents and Settings\myname\Local Settings\Temp\magick-k7eu50bt
C:\Documents and Settings\myname\Local Settings\Temp\magick-kbaqoqbu

It is actually filling up my hard disk, before the memory test goes through. I cannot find posts about this. Any help would be greatly appreciated.

Posted: 2006-06-26T07:13:16-07:00
by magick
ImageMagick creates temporary files for a variety of reasons. They are removed as long as the process is not killed or if a soft-signal is thrown that ImageMagick can catch. It is safe to remove these as long as you do not have any ImageMagick processes running.

Posted: 2006-06-26T07:24:13-07:00
by swiss_knife
That's a problem, because my Magick process runs for hours. After some time, I end up with hundreds of Megs of such files. What is the Magick function creating those ?

Can we prevent the creation of such files. Is there a flag telling me I can delete a specific magick-XXXX file? I am catching exceptions thrown by Magich here and there on some images. That's what causing the creation of these files?

Posted: 2006-07-18T09:07:46-07:00
by swiss_knife
Can we prevent the creation of such files ??? It must have a way. It is kind of understandable that the creation of such files is a problem if a user kill my process once in a while.
Thank you.

Posted: 2006-07-19T20:17:17-07:00
by magick
ImageMagick has a need to create temporary files depending on what you are doing. In some cases you can prevent them from being created. For example, you can set the resource limits such that all images are created in memory rather than disk (see http://magick.imagemagick.org/script/architecture.php for a discussion). ImageMagick will remove them if the program exits properly or if certain signals are thrown. ImageMagick, for example, intercepts the ctrl-C interrupts and remove temporary files on anything but Windows. Windows does not follow the POSIX signal specification. We did put a catch in for Windows for ctrl-C but apparently it does not work properly and we're waiting for a Windows-savvy developer to help us resolve this problem. We used to have a atexit() handler to remove the remporary files but some folks complained it was causing problems for embedded applications so we removed the atexit() call. You of course can restore it to your local version of the ImageMagick source distribution.

Re: tons of magick-XXXX files in C:\Documents and Settings

Posted: 2007-02-20T03:28:45-07:00
by swiss_knife
Thanks for this precise answer. Is this problem still in the latest Image-Magick version for Windows ? If it is, could you put the atexit() code in a #ifdef WIN32 paragraph ?? The problem is I am using Image-Magick in the application that I am selling, but my code is called in another environment where I don't have control on signals and so on, and after some time (a few weeks), the hard disk is getting filled with 611 990 KB files like magick-v4qlhq51, magick-sg2mg7u5, etc

Re: tons of magick-XXXX files in C:\Documents and Settings

Posted: 2007-02-21T20:17:43-07:00
by anthony
You could always check the date on these files and remove them if they are say more than an hour old. Depends on you application.

The point however is that if IM is left to run to completion then it should not leave tehse files. Do you have a timeout for the web application whcih may be the culprit?

prehaps each web job should use a different temp, and that whole directory can then be junked when that request is fiished.

Re: tons of magick-XXXX files in C:\Documents and Settings

Posted: 2007-02-23T04:29:39-07:00
by swiss_knife
Actually my app is not a web app. My stuff is getting called from another application that can signal me for termination or just fill my process.

Re: tons of magick-XXXX files in C:\Documents and Settings

Posted: 2007-02-24T22:58:31-07:00
by anthony
It is those signals that are causing you problems. You may be able to wrap the IM call in something to pass on the signal, wait, then cleanup, when it sees a signal.

This will work for any signal but signal 9 (unstoppable), and can be a simple shell script that also sets the MAGICK_TMPDIR environment vaibale to a directory the script can just recursivally delete when IM finishes or a terminate is passed on.

You will however need a signals savy UNIX programmer for this.

Re: tons of magick-XXXX files in C:\Documents and Settings

Posted: 2007-07-30T06:15:19-07:00
by swiss_knife
We did put a catch in for Windows for ctrl-C but apparently it does not work properly and we're waiting for a Windows-savvy developer to help us resolve this problem. We used to have a atexit() handler
Hey "magick",
if you could point me out exactly where this code is in Magick, I am willing to have a look at this CTRL C handler and this atexit() function. Thank you.

Re: tons of magick-XXXX files in C:\Documents and Settings

Posted: 2007-07-30T06:50:40-07:00
by magick
Take a look at NTControlHandler() in magick/nt-base.c. We currently do not call it but we can restore the call if you get it to work properly.

Re: tons of magick-XXXX files in C:\Documents and Settings

Posted: 2008-03-01T09:29:59-07:00
by ptast
Magick,

Could it be possible to save the temporary data to eg C:\Documents and Settings\myname\Local Settings\Temp\ImageMagic and at startup delete all files and this would make it possible also for the calling (linked to IM) application to remove them?

I just noted that I had five 2gb (10gb of junk) magick-.... files in my temp directory....

Re: tons of magick-XXXX files in C:\Documents and Settings

Posted: 2009-08-21T07:20:14-07:00
by wogabog
Someone should take the time to look at & fix this issue in Windows, I just cleaned up over 300GB of magick-XXXX files in my user "Local Settings\temp" directory, some of them up to 80GB each!

It's not pleasant to find Imagemagick using up ~50% of my disk space. :shock:

Re: tons of magick-XXXX files in C:\Documents and Settings

Posted: 2009-08-21T08:11:32-07:00
by magick
We can only fix problems that we can reproduce. Post a command line or code snippets that leaves magick-* temporary files after the process finishes. If a temporary file remains it is a bug known as a file leak. Hopefully we will be able to reproduce the problem and we will fix the file leak within a day or two. As of today, with the current ImageMagick release (6.5.4-10), there are no known file leaks.

As previously mentioned, like most programs, ImageMagick cannot clean-up temporary files if it is interrupted and does not exit gracefully. We can catch some soft signals but certain signals such as SIGKILL does not provide an opportunity for ImageMagick to clean-up and exit gracefully. Under these circumstances, you must manually remove any temporary files.