Resource leak in AcquireVirtualMemory

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
anorland
Posts: 2
Joined: 2016-01-07T03:23:23-07:00
Authentication code: 1151

Resource leak in AcquireVirtualMemory

Post by anorland »

Hi,

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: https://github.com/ImageMagick/ImageMagick/pull/75


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,
Anders
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Resource leak in AcquireVirtualMemory

Post 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.
anorland
Posts: 2
Joined: 2016-01-07T03:23:23-07:00
Authentication code: 1151

Re: Resource leak in AcquireVirtualMemory

Post by anorland »

Great, thanks!
Post Reply