Comment 23 for bug 1677578

According to [1] I should be able to set that limit for cli scripts as well.
If possible that would take a lot of things (lighthttpd/cgi) out of the equation so lets try this.

The minimal repro IMHO is this, which makes the problem fairly easy to be discussed.
This is more or less my prep on a report to PHP.

# Prep image
$ convert -size 16384x16384 xc:white test.png

# Ensure with a Test that the Limit is in place
$ php -d memory_limit=2M -r 'for ($i = 0; $i<100; $i++){ $a[$i] = array_fill(0, 16384, '1234567890-foobar'); }'
PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 528384 bytes) in Command line code on line 1

# Run the example exceeding the Limit
$ /usr/bin/time -v php -d memory_limit=2M -r '$image = new \Imagick("y.png");'
Maximum resident set size (kbytes): 5047096

Note: on more recent versions of Imagemagick you might have to lift/disable some default limits in /etc/ImageMagick-6/policy.xml

Confirmed on Xenial and Zesty with php v7.0.15

I'm note sure on the security/limits model into plugins like ImageMagick here, but want at least to report it. Searching for it only gives me zillion of pages showing me how to raise the limits :-/
I'm fine getting told that it is a bug in the plugin if that really is the case.