We use Python Wand under Celery to process a lot of pictures. On some of our servers, our treatment sometimes leaves a lot of temporary files behind, e.g.:
$ ls -lh /tmp/
-rw------- 1 ubuntu ubuntu 1.9M Apr 1 04:35 magick-y1yKKiVZ
-rw------- 1 ubuntu ubuntu 1.9M Apr 1 04:41 magick-Y22P6McK
-rw------- 1 ubuntu ubuntu 1.9M Apr 1 04:37 magick-YaaSIYrk
-rw------- 1 ubuntu ubuntu 1.9M Apr 1 04:39 magick-YEkn4H15
-rw------- 1 ubuntu ubuntu 1.9M Apr 1 04:39 magick-yf2Vrfwi
-rw------- 1 ubuntu ubuntu 1.9M Apr 1 04:38 magick-YIYTaArn
-rw------- 1 ubuntu ubuntu 199K Apr 1 04:43 magick-YLM5wYm9
-rw------- 1 ubuntu ubuntu 199K Apr 1 04:43 magick-YLo5SeVp
[...]
Is there a way to make Wand clean up after it worked on some file? If it's the expected behavior, is there a way to debug this and know which image created which temp file, by putting a log statement for example?
Thanks
Easy way:
In your environment settings point MAGICK_TMPDIR=/home/somewhere
and rm magick-*
that folder in your crontab.
Hard way: Apply this path to ImageMagick before compiling:
--- pristine/imagemagick-6.5.7.8/magick/resource.c 2009-10-26 16:52:10.000000000 +0300
+++ libm/imagemagick-6.5.7.8/magick/resource.c 2010-09-28 19:18:39.000000000 +0400
@@ -329,6 +329,7 @@
static void *DestroyTemporaryResources(void *temporary_resource)
{
(void) remove((char *) temporary_resource);
+ RelinquishMagickMemory(temporary_resource);
return((void *) NULL);
}
@@ -474,10 +475,10 @@
(void) LockSemaphoreInfo(resource_semaphore);
if (temporary_resources == (SplayTreeInfo *) NULL)
temporary_resources=NewSplayTree(CompareSplayTreeString,
- RelinquishMagickMemory,DestroyTemporaryResources);
+ DestroyTemporaryResources, NULL);
(void) UnlockSemaphoreInfo(resource_semaphore);
resource=ConstantString(path);
- (void) AddValueToSplayTree(temporary_resources,resource,resource);
+ (void) AddValueToSplayTree(temporary_resources,resource,NULL);
return(file);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With