help! I'm getting "out of memory" errors when trying to resize an image

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lawrence k

    help! I'm getting "out of memory" errors when trying to resize an image

    I've a jpeg image that is 514k, which doesn't strike me as very large.
    Yet I'm running out of error when I try to resize it:

    Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to
    allocate 12288 bytes) in
    /home/httpd/vhosts/monkeyclaus.org/httpdocs/media/audio/pdsIncludes/resizeImageToSq uare.php
    on line 82


    How can I protect against out-of-memory errors?

  • Rik

    #2
    Re: help! I'm getting "out of memory" errors when trying to resize an image

    lawrence k wrote:
    I've a jpeg image that is 514k, which doesn't strike me as very large.
    Well, it is 514K in compacted mode. When creating in image with GD it cen
    quickly become very large.
    Yet I'm running out of error when I try to resize it:
    >
    Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to
    allocate 12288 bytes) in
    >
    /home/httpd/vhosts/monkeyclaus.org/httpdocs/media/audio/pdsIncludes/resizeImageT
    oSquare.php
    on line 82
    >
    >
    How can I protect against out-of-memory errors?
    Well, you could try to check your usage on various points in the script with
    memory_get_usag e(), and check what is causing it. You might be able to do things
    more effeciently.

    Number one protection against out-of-memory errors is descent code, but even
    descent code may need more. If you truly need more memory, you should up the
    memory limit.

    Grtz,
    --
    Rik Wasmus


    Comment

    • m2m tech

      #3
      Re: help! I'm getting "out of memory" errors when trying to resizean image

      .... or just increase the availabe memory:

      ini_set('memory-limit', '8M');

      Rik wrote:
      lawrence k wrote:
      >
      >>I've a jpeg image that is 514k, which doesn't strike me as very large.
      >
      >
      Well, it is 514K in compacted mode. When creating in image with GD it cen
      quickly become very large.
      >
      >
      >>Yet I'm running out of error when I try to resize it:
      >>
      >>Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to
      >>allocate 12288 bytes) in
      >>
      >
      /home/httpd/vhosts/monkeyclaus.org/httpdocs/media/audio/pdsIncludes/resizeImageT
      oSquare.php
      >
      >>on line 82
      >>
      >>
      >>How can I protect against out-of-memory errors?
      >
      >
      Well, you could try to check your usage on various points in the script with
      memory_get_usag e(), and check what is causing it. You might be able to do things
      more effeciently.
      >
      Number one protection against out-of-memory errors is descent code, but even
      descent code may need more. If you truly need more memory, you should up the
      memory limit.
      >
      Grtz,

      --
      --------------------------------------------
      m2m server software gmbh - http://www.m2m.at

      Comment

      • Andrew Poelstra

        #4
        Re: help! I'm getting "out of memory" errors when trying to resize an image

        m2m tech <tech@m2m.atwri tes:
        ... or just increase the availabe memory:
        >
        ini_set('memory-limit', '8M');
        Please stop topposting. Responses belong below or interspersed with the
        original post, because that's how people read: top to bottom.

        --
        Andrew Poelstra <http://www.wpsoftware. net/projects>
        To reach me by email, use `apoelstra' at the above domain.
        "Do BOTH ends of the cable need to be plugged in?" -Anon.

        Comment

        • Alvaro G. Vicario

          #5
          Re: help! I'm getting &quot;out of memory&quot; errors when trying to resize an image

          *** lawrence k escribió/wrote (17 Aug 2006 13:46:54 -0700):
          I've a jpeg image that is 514k, which doesn't strike me as very large.
          JPEG has a very good compression algorithm, like a 10% of original file. So
          you can expect the uncompressed file to take 5MB of memory (at a minimum).

          You don't say what method you're using, neither paste actual code. But if
          your script creates several temp images and loads them all into memory,
          that'd be an explanation for running out of memory having 20MB to play
          with. Have a look at it and see if you can optimize it. Using more than
          20Mb to resize a JPEG is crazy.



          --
          -+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
          ++ Mi sitio sobre programación web: http://bits.demogracia.com
          +- Mi web de humor con rayos UVA: http://www.demogracia.com
          --

          Comment

          Working...