That function will not prevent your script from trying to use more memory than it has available. You should use the logic discussed earlier in the thread.
As crmalibu stated, you should be checking the amount of memory possibly available, against the calculated memory needed and making a desicion.
Here’s some pseudo code:-
<?php
if (ESTIMATED_MEMORY_REQUIRMENT <= MAX_SYSTEM_MEMORY)
{
PROCESS_IMAGE;
}
else
{
SHOW_ERROR;
}
?>
Change MAX_SYSTEM_MEMORY to MAX_SYSTEM_MEMORY - CURRENTLY_ALLOCATED_MEMORY - ANOTHER_MB_OR_SO. You need to account for whatever memory the script is already using. You also need to give yourself enough memory so that you can process other statements until you can destroy the image resource, which will free all that memory up. Otherwise the script might crash on the next few lines.
Good point crmalibu, as always.
Hi guys thanks for the help. To alleviate checking for avaliable memory and the sort I decided to limited the resolution size and MB size that could be uploaded for a given image. This works better for me and thus the user knows ahead of time.
I ran a few tests and finalized that with my current hosting company I can upload a image that is 3200 x 2800 or smaller and that is not larger than 4MB. This lets me relay this to the user so they know what they can upload.
I greatly appreciated all of you help.