Imagemagick memory allocation failed
-
When generation previews of larger images, Imagemagick can run into an error:
convert-im6.q16: memory allocation failed
Expanding the allowed memory in the policy file would allow larger image files to have previews generated:
/etc/ImageMagick-6/policy.xml
<policy domain="resource" name="area" value="256MB"/> <policy domain="resource" name="memory" value=“1GiB"/> <policy domain="resource" name="map" value=“2GiB"/> <policy domain="resource" name="disk" value=“4GiB"/>
It may be appropriate for the IM policy to be customized based on the system it runs on, since some servers may be resource limited.
-
-
The default imagemagick policy.xml is fairly conservative. It's not meant for handling larger image files that Nextcloud is often used for. A similar
Cache resources exhausted
error is also related to the policy.xml settings.Some resources:
https://legacy.imagemagick.org/discourse-server~/viewtopic13c6.html?p=172497#p172497
https://github.com/ImageMagick/ImageMagick/issues/396#issuecomment-326849298
-
It seems the defaults are:
<policy domain="resource" name="memory" value="256MiB"/> <policy domain="resource" name="map" value="512MiB"/> <policy domain="resource" name="width" value="16KP"/> <policy domain="resource" name="height" value="16KP"/> <!-- <policy domain="resource" name="list-length" value="128"/> --> <policy domain="resource" name="area" value="128MB"/> <policy domain="resource" name="disk" value="1GiB"/>
-
The default imagemagick policy.xml is fairly conservative. It's not meant for handling larger image files that Nextcloud is often used for. A similar
Cache resources exhausted
error is also related to the policy.xml settings.Some resources:
https://legacy.imagemagick.org/discourse-server~/viewtopic13c6.html?p=172497#p172497
https://github.com/ImageMagick/ImageMagick/issues/396#issuecomment-326849298
-
-
@girish
I should mention that on certain systems, Nextcloud's preview generation can push ImageMagick to consume all the cpu resources, freezing the frontend.To ensure that ImageMagick never hinders Nextcloud, I would recommend these policy changes:
<policy domain="resource" name="thread" value="1"/> <policy domain="resource" name="throttle" value="100"/>
The first line limits IM to use only one CPU thread. The second line has IM give at least 100ms to other CPU tasks so it's never taking 100% of the CPU.