I have to render something with Imagick on PHP CLI. I have noticed that every 3-5 days the server memory gets full, so i can\'t even connet via ssh or ftp.
with memo
You can use this.
Note that clear()
is preferred over destroy()
according to the docs to release memory use.
// clear temp files
$imagick_image->clear(); // in your case "$img->clear();"
You can also run a cron to delete the temp files for you, otherwise your server could crash. This is not php code, it is command line code.
# linux command
find /tmp/ -name "magick-*" -type f -delete
# cron
45 * * * * find /tmp/ -name "magick-*" -type f -delete