Page 1 of 1

Resource leak in AcquireVirtualMemory

Posted: 2016-01-07T05:29:00-07:00
by anorland

There is a resource leak in AcquireVirtualMemory resulting in major performance degradation whenever AcquireMagickResource starts returning false. The problem is that AcquireMagickResource calls are not paired with calls to RelinquishMagickResource if a resource limit is hit.

Eventually all allocations and pixel caches will start using file-backed storage leading to major performance degradations.

Another issue is that AcquireVirtualMemory does not remove temporary files created for failed file-backed memory mappings. This has been adressed in IM 7.

I have created a pull request for you to review:

Something I've discovered is that OpenPixelCache and AcquireVirtualMemory count resources a bit differently.
AllocatePixelCachePixels attempts an anonymous mapping when regular allocation fails, thus counting towards the Memory limit, while AcquireVirtualMemory counts them towards the Map limit.

Best regards,

Re: Resource leak in AcquireVirtualMemory

Posted: 2016-01-07T06:48:07-07:00
by magick
We applied your patch to the GIT master and branches. Thanks for your contribution.

We'll also add a patch to fix the memory vs. map resource allocation. Thanks for alerting us to the problem.

Re: Resource leak in AcquireVirtualMemory

Posted: 2016-01-07T12:05:33-07:00
by anorland
Great, thanks!