Imagemagick memory allocation failed
- 
When generation previews of larger images, Imagemagick can run into an error: convert-im6.q16: memory allocation failedExpanding 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. 
- 
 N nebulon marked this topic as a question on N nebulon marked this topic as a question on
- 
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 exhaustederror 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"/>
- 
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 exhaustederror 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 
- 
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 exhaustederror 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 
- 
@nikkuexe I have adjusted it here - https://git.cloudron.io/cloudron/nextcloud-app/-/commit/e7dc56f0fad6bbade59aede429b3ff34096e96b9 
- 
 G girish has marked this topic as solved on G girish has marked this topic as solved on
- 
@nikkuexe I have adjusted it here - https://git.cloudron.io/cloudron/nextcloud-app/-/commit/e7dc56f0fad6bbade59aede429b3ff34096e96b9 @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. 
- 
@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. 
 
