Page 1 of 1

cache resources exhausted -> disk limit not freed

Posted: 2013-08-08T07:16:13-07:00
by jpastuszek
Hi,

I am using IM in my thumbnailing server.
I have a problem with pixel cache.
When I try to load or to thumbnail image that is too big to fit in disk mapped cache I get error from IM and serve 413 to my clients.
The problem is that IM does not free disk cache resource after that error although memory resource is feed. So next request with large image enough to hit disk but not bigger than the limit will fail. All subsequent requests that do fit in memory limit are OK.
If I restart server/IM and do just this last request it will work OK.

Here is the debug trace:

Code: Select all

2013-08-08T15:53:55+02:00 0:06.570 -1.090u 6.8.0 Resource ruby[74165]: resource.c/AcquireMagickResource/262/Resource
  Area: 4.4401GB/4.4401GB/4.295GB
2013-08-08T15:53:55+02:00 0:06.570 -1.090u 6.8.0 Resource ruby[74165]: resource.c/AcquireMagickResource/262/Resource
  Disk: 4.4401GB/4.1352GiB/1GiB
2013-08-08T15:53:55+02:00 0:06.570 -1.080u 6.8.0 Exception ruby[74165]: cache.c/OpenPixelCache/4074/Exception
  cache resources exhausted `'
2013-08-08T15:53:55+02:00 0:06.570 -1.080u 6.8.0 Exception ruby[74165]: jpeg.c/JPEGErrorHandler/315/Exception
  Application transferred too few scanlines `'
2013-08-08T15:53:55+02:00 0:06.570 -1.080u 6.8.0 Exception ruby[74165]: constitute.c/ReadImage/613/Exception
  Coder (JPEG) generated an image despite an error (445), notify the developers

2013-08-08T15:53:59+02:00 0:09.890 -1.020u 6.8.0 Resource ruby[74165]: resource.c/AcquireMagickResource/262/Resource
  Area: 277.5MB/277.5MB/4.295GB
2013-08-08T15:53:59+02:00 0:09.890 -1.020u 6.8.0 Resource ruby[74165]: resource.c/AcquireMagickResource/262/Resource
  Memory: 277.5MB/264.7MiB/125.6MiB
2013-08-08T15:53:59+02:00 0:09.890 -1.020u 6.8.0 Resource ruby[74165]: resource.c/RelinquishMagickResource/814/Resource
  Memory: 277.5MB/0B/125.6MiB
2013-08-08T15:53:59+02:00 0:09.890 -1.020u 6.8.0 Resource ruby[74165]: resource.c/AcquireMagickResource/262/Resource
  Disk: 277.5MB/4.3937GiB/1GiB
2013-08-08T15:53:59+02:00 0:09.890 -1.020u 6.8.0 Exception ruby[74165]: cache.c/OpenPixelCache/4074/Exception
  cache resources exhausted `'
2013-08-08T15:53:59+02:00 0:09.890 -1.020u 6.8.0 Exception ruby[74165]: jpeg.c/JPEGErrorHandler/315/Exception
  Application transferred too few scanlines `'
2013-08-08T15:53:59+02:00 0:09.890 -1.020u 6.8.0 Exception ruby[74165]: constitute.c/ReadImage/613/Exception
  Coder (JPEG) generated an image despite an error (445), notify the developers
So basically it looks that I am trying to allocate 4.4401GB which ends up trying to allocate 4.1352GiB disk and fails because the limit is 1GiB.
Next request is taking 277.5MB which is more than 125.6MiB of memory limit so it ends up trying disk which apparently has already used up 4.3937GiB of 1GiB limit.
So the only option I have here is to restart the server every time I hit the cache limit to free up the disk limit...

I am using IM v6.8.0-7, but this also happens with v6.8.5.
I hope this is useful.
If you need more info/debugging please ping me on e-mail.

Regards,
Jakub

Re: cache resources exhausted -> disk limit not freed

Posted: 2013-08-08T07:44:31-07:00
by magick
We can reproduce the problem you posted and have a patch in ImageMagick 6.8.6-9 Beta available by sometime tomorrow. Thanks.