Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


    Cloudron Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Solved Imagemagick memory allocation failed

    Nextcloud
    2
    7
    841
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • nikkuexe
      nikkuexe last edited by

      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.

      1 Reply Last reply Reply Quote 1
      • Topic has been marked as a question  nebulon nebulon 
      • nikkuexe
        nikkuexe @girish last edited by

        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

        https://stackoverflow.com/a/53699200

        girish 1 Reply Last reply Reply Quote 0
        • girish
          girish Staff last edited by

          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"/>
          
          nikkuexe 1 Reply Last reply Reply Quote 0
          • nikkuexe
            nikkuexe @girish last edited by

            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

            https://stackoverflow.com/a/53699200

            girish 1 Reply Last reply Reply Quote 0
            • girish
              girish Staff @nikkuexe last edited by

              @nikkuexe I have adjusted it here - https://git.cloudron.io/cloudron/nextcloud-app/-/commit/e7dc56f0fad6bbade59aede429b3ff34096e96b9

              nikkuexe 2 Replies Last reply Reply Quote 2
              • nikkuexe
                nikkuexe @girish last edited by

                @girish It works. Thanks for the update.

                1 Reply Last reply Reply Quote 0
                • Topic has been marked as solved  girish girish 
                • nikkuexe
                  nikkuexe @girish last edited by

                  @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 1 Reply Last reply Reply Quote 1
                  • girish
                    girish Staff @nikkuexe last edited by

                    @nikkuexe thanks. Applied the patch here https://git.cloudron.io/cloudron/nextcloud-app/-/commit/1886a32f4d15724cfc3af74fbc0f07772ccba13b

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Powered by NodeBB