Page 1 of 1

Need to remove memory usage limit

Posted: 2018-10-09T09:48:17-07:00
by daveotto
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.

Re: Need to remove memory usage limit

Posted: 2018-10-09T10:08:35-07:00
by daveotto
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?

Re: Need to remove memory usage limit

Posted: 2018-10-09T10:18:27-07:00
by snibgo
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?

Re: Need to remove memory usage limit

Posted: 2018-10-09T10:25:35-07:00
by fmw42
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.

Re: Need to remove memory usage limit

Posted: 2018-10-09T10:57:36-07:00
by daveotto
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...