dlemstra / Magick.NET

The .NET library for ImageMagick
Apache License 2.0
3.42k stars 413 forks source link

Magick.net creating huge temporary files in Windows server: magick-xxxxxxxxxxxx #1401

Open guru248 opened 1 year ago

guru248 commented 1 year ago

Magick.NET version

Magick.Net Q-16 Any CPU - 13.0.1

Environment (Operating system, version and so on)

Windows server 2016, 64 bit

Description

Magick.net is creating huge temporary files and are not getting automatically deleted in Windows server. Screenshot attached. image As seen in the screenshot, it has accumulated to 1.4 TB in one server in less that 4 months. Magick application runs continuously as a task and processes images in big numbers everyday.

Kindly suggest a solution to this as manual deletion can only be seen as a temporary work around.

Steps to Reproduce

There are no steps to reproduce as this is not happening everyday, rather randomly but often. The application just generates a resized preview and thumbnail for images.

dlemstra commented 1 year ago

Those files will be created when ImageMagick cannot allocate the memory required for the pixels of an image. You probably have some ridiculous big images that are being resized. And when this get aborted due to time limits or an app pool recycle it is possible that these files remain on disk. One solution would be to disallow these kind of images by setting the ResourceLimits. But if you want to allow these kind of images you will need to create something that cleans up these files. A program that deletes magick-* files older than a day from the temp directory should probably be the solution for this.

guru248 commented 1 year ago

Thanks. We cannot avoid the large files, so we'll schedule a task to delete the same. Another query, do you think this will still happen if we migrate to Azure cloud?

dlemstra commented 1 year ago

It all depends on how you will run your application in Azure so I cannot really give you an answer. You will need to cleanup these files if you are using a long running instance. When you use a short living instance you probably don't need to do this.