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


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Nextcloud
  3. Imagemagick memory allocation failed

Imagemagick memory allocation failed

Scheduled Pinned Locked Moved Solved Nextcloud
7 Posts 2 Posters 3.3k Views 2 Watching
  • 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.
  • nikkuexeN Offline
    nikkuexeN Offline
    nikkuexe
    wrote on last edited by
    #1

    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
    1
    • nebulonN nebulon marked this topic as a question on
    • girishG girish

      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"/>
      
      nikkuexeN Offline
      nikkuexeN Offline
      nikkuexe
      wrote on last edited by
      #3

      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

      girishG 1 Reply Last reply
      0
      • girishG Offline
        girishG Offline
        girish
        Staff
        wrote on last edited by
        #2

        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"/>
        
        nikkuexeN 1 Reply Last reply
        0
        • girishG girish

          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"/>
          
          nikkuexeN Offline
          nikkuexeN Offline
          nikkuexe
          wrote on last edited by
          #3

          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

          girishG 1 Reply Last reply
          0
          • nikkuexeN nikkuexe

            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

            girishG Offline
            girishG Offline
            girish
            Staff
            wrote on last edited by
            #4

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

            nikkuexeN 2 Replies Last reply
            2
            • girishG girish

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

              nikkuexeN Offline
              nikkuexeN Offline
              nikkuexe
              wrote on last edited by
              #5

              @girish It works. Thanks for the update.

              1 Reply Last reply
              0
              • girishG girish has marked this topic as solved on
              • girishG girish

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

                nikkuexeN Offline
                nikkuexeN Offline
                nikkuexe
                wrote on last edited by
                #6

                @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.

                girishG 1 Reply Last reply
                1
                • nikkuexeN nikkuexe

                  @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.

                  girishG Offline
                  girishG Offline
                  girish
                  Staff
                  wrote on last edited by
                  #7

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

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Bookmarks
                  • Search