#660385 php5-imagick: ignores memory limit

Package:
php5-imagick
Source:
php-imagick
Submitter:
Arkadiy Kulev
Date:
2023-04-18 12:45:08 UTC
Severity:
normal
Tags:
#660385#5
Date:
2012-02-18 18:41:22 UTC
From:
To:
No matter how big I set the memory limit to, imagick still keeps processing the image through a file on the disk.
Here is my php code:

$img = new Imagick();
$img->setResourceLimit(imagick::RESOURCETYPE_MEMORY, 1024*1024*1024); # i know this is stupid, but even 0, or 100, or 1024 don't work.
$img->readImage($tempfile);

here is a strace:

open("/tmp/magick-XXtLR7h2", O_RDWR|O_CREAT|O_EXCL, 0600) = 5
fstat(5, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
brk(0x2797000)                          = 0x2797000
read(4, "\377\330\377\340\0\20JFIF\0\1\1\0\0\1\0\1\0\0\377\333\0C\0\1\1\1\1\1\1\1"..., 245760) = 245760
read(4, "\274\237\323\357\205d\270\273\271`\312\320\35\f\224\272\207X\273\260>\234\0179c\366\254&*\223L\363"..., 4096) = 4096
write(5, "\377\330\377\340\0\20JFIF\0\1\1\0\0\1\0\1\0\0\377\333\0C\0\1\1\1\1\1\1\1"..., 245765) = 245765

#660385#10
Date:
2012-04-30 09:17:14 UTC
From:
To:
Hello,

The resource type RESOURCETYPE_MEMORY on php-imagick corresponds to
ImageMagick MAGICK_MEMORY_LIMIT, which define how much memory could be
use to reserve memory for tasks and when the limit is reached, cached
memory-mapped disk is used:

http://fr2.php.net/manual/en/imagick.setresourcelimit.php
http://www.imagemagick.org/script/resources.php#environment

So whatever value you use in setResourceLimit for RESOURCETYPE_MEMORY,
the tasks are processed (less or more quickly).