Hi,

I have an imagecreatefromjpeg error that I am trying to handle without an error being echoed.

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 14720 bytes) in /home/showthos/public_html/scratch/test.php on line 32

If have tried putting an @symbol infront of the imagecreatefromjpeg(); however, it just completely halts the script. won't even execute one line past the command.

I have also tried a try / catch but that didn't work either.

Finally, I tried to suppress errors entirely using error_reporting(0); however that does let the script continue either.

I know how to fix the error; however, I would like to be able to catch it just in case it ever happens again...

I'd appreciate any help,

Thanks,

slevytam

    The problem is that running out of memory is fatal. Once it happens, you're dead.

    Al I can suggest is to use [man]getimagesize/man to get the pixel width and height, multiply them together for the total number of pixels, and multiply that by 4 to get the max number of bytes that will be needed to store the working bitmap in memory. If that number is over whatever number you choose to be "too big", then either do not do the image creation and return some sort of "image too big" error, or else use [man]ini_set/man to increase the memory_limit setting to an appropriate value.

      NogDog wrote:

      The problem is that running out of memory is fatal. Once it happens, you're dead.

      Hence the term "Fatal error", I guess 🙂

        Weedpacket;10905379 wrote:

        Hence the term "Fatal error", I guess 🙂

        Occasionally I find that sometimes repetition and redundancy can be helpful and beneficial.

          Write a Reply...