Jump to content

[SOLVED] Weird out of memory situation


phpknight

Recommended Posts

I am running a script where I upload large images.  I get the peak memory before and after each time I use it.  To create the image I use:

 

$image=imagecreatefrompng($_FILES['theFiles']['tmp_name'][$fileNumber]);

 

What is weird is that 4500x4500 png works fine and doesn't come close to the 400MB limit for the script, but for sme reason 4499x4499 fails and so does 4501x4501.  Other lower sizes fail as well, but 2999x2999 works.  Any idea what might be going on here?  I can't really believe that the script is out of memory.  Even the errors say Out of memory (allocated 104,595,456) (tried to allocate 80,964,004 bytes) .  But both those numbers are well below the limit.  I tried to figure out if a certain PNG of max dimensions X x Y caused it, but it like I said 4500 works but 4499 doesn't.

 

PHP version is 5.2.3.

 

Any ideas?

 

 

Link to comment
Share on other sites

Okay, I may have solved the problem but do not know why.  I am on a dedicated box.  If I set the memory limit in the ini file itself AND the script, all the files uploads seem to work.  But if I only set the INI or only the script (even with the corrected ini file), then the above files do not work.  Any ideas? 

 

Link to comment
Share on other sites

It is likely that the syntax being used to set them is not correct. Post actual examples.

 

It is also possible that the php.ini that you are making changes to is not the one that php is using. The memory limit being set in the script would override any setting in php.ini, assuming the syntax is correct.

Link to comment
Share on other sites

I'm going to mark this one as solved, but please reply if you have an idea.  After more exploration, I realized that if I set the memory limit in the script way over the ini, the script does not always work probably even though outputting the result shows that the ini value does get changed.  However, if I set the ini high, I can limit the scripts just fine by putting a lower number, and the scripts halt as expected at the lower levels. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.