Forum Moderators: coopster

Message Too Old, No Replies

Imagick memory leaks. Alternatives?

         

httpwebwitch

2:44 am on Oct 24, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The PHP Imagick library has irreconcilable memory leaks. I have a script that does a little image manipulation, and every time it's run it gobbles a piece of memory and never gives it back.

So I'm looking for an alternative. It's sad because I worked really hard on getting my script to work perfectly, and then discovered I can't use it in production.

Is Gmagick better?
[php.net...]

How about GD?
[php.net...]

Suggestions?

httpwebwitch

12:38 pm on Oct 25, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I converted my image manipulation script into something I could run from the CLI. There, it consumes memory while it's working but the memory is released again when it's finished.

So the problem seems to be not with the Imagick library itself, but with the Apache/PHP interface with it. Works great as a script run from the command line. When the same script is run as part of an Apache request, memory is snapped up and never given back.

Immensely frustrating. But at least there's a way for me to get my work done.

Serves me right; image crunching is an intensize process and isn't supposed to be something we do synchronously as part of a web request - it's a perfect task for delegating to a queued worker. I know this, I was just being lazy.

phranque

9:38 pm on Oct 25, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



it would probably work OK as a CGI script as well.

penders

9:11 pm on Oct 26, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just curious how your Apache/PHP is setup? Module, FastCGI, etc? Could that play a part?

httpwebwitch

8:50 pm on Nov 6, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



on this particular server, PHP is set up as an Apache module.

I don't know if it would work differently if I ran the script on an nginx/FastCGI stack. Perhaps that's an experiment for another day.