Need to remove memory usage limit

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
daveotto
Posts: 3
Joined: 2018-10-09T09:30:33-07:00
Authentication code: 1152

Need to remove memory usage limit

Post by daveotto » 2018-10-09T09:48:17-07:00

I work for a company that has used ImageMagick for a long time, through MagickCore with C and C++. We were using a very old version until now. That version, when loading a large animated gif, would spike mem usage up to about 5GB and get the job done in about 5 seconds. We liked that just fine.

Now, we are upgrading to (relatively) current code. When we load the same gif now, mem usage caps at about 1.7GB but the file takes about 5 minutes to load. Not ok with us. How can I remove that limit? I have tried changing the line "memory" in policy.xml from 2GiB to 6GiB, but it seems to have no effect on the mem use, which still caps around 1.7GB. Are there some other policy lines I should put there to affect this? Can I just go in the code somewhere and remove the limit? I'll be pursuing this line, just hoping for some hints here to make this go quicker.

daveotto
Posts: 3
Joined: 2018-10-09T09:30:33-07:00
Authentication code: 1152

Re: Need to remove memory usage limit

Post by daveotto » 2018-10-09T10:08:35-07:00

I took out the policy file usage, but still seem to be getting my mem use capped at about 1.7GB. Where is that coming from?

snibgo
Posts: 10697
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Need to remove memory usage limit

Post by snibgo » 2018-10-09T10:18:27-07:00

What versions of IM, on what platform?

What makes you think the memory is capped at 1.7GB? Perhaps the program only needs that much.

What does your code do?
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 23833
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Need to remove memory usage limit

Post by fmw42 » 2018-10-09T10:25:35-07:00

There are several possible locations for the policy.xml file. Are you sure you only have one and did you edit it correctly and perhaps restart. You can try commenting out that policy line.

See https://imagemagick.org/script/resources.php for the possible locations and priority.

I am assuming that this is your server and not a shared server. If the latter, your hosting provider has control of the limitations and you can only make them tighter not looser. If this is your server, then you should have full control.

daveotto
Posts: 3
Joined: 2018-10-09T09:30:33-07:00
Authentication code: 1152

Re: Need to remove memory usage limit

Post by daveotto » 2018-10-09T10:57:36-07:00

I'm watching the program stats in task manager on win10 or in devstudio 2015. Old program, old IM, goes up to about 6GB mem while reading, then back down. New program, new IM, goes up to about 1.7GB mem and levels off, but then the disk access spikes to max for minutes on end until the file is done reading.

This behavior is observed in the devstudio 2015 diagnostic tools during calls to ReadImage and CoalesceImages while loading a file.

Looks like ReadImage calls DecodeImage, which allocates 22MB per frame. There are 411 frames, which should use about 8GB. When we hit 1.7GB, DecodeImage stops increasing the mem set, and disk access starts. This is an x64 C++ program so no 2GB limits. Continuing the dig...

Post Reply