User Tools

Site Tools


Sidebar

tutorials:memory_errors:start

This is an old revision of the document!


PHP Memory Limit Error When Using Software

This error most often happens when clients of your are uploading images to attach to their listings but can occur in some instances under basic script use with the default php memory limit value set at 8MB. The most common error looks something like (if you see one in the browser at all):

Fatal error: Allowed memory size of ######## bytes exhausted (tried to allocate ##### bytes) in /home/public_html/classes/order_items/images.php on line ####

Errors within the Categories admin tool...usually copying categories

The above error means that PHP does not have sufficient memory to do what it is trying to do within our software. This error can appear when managing large amounts of categories within the admin tool as a few queries need to be sometimes on many categories to create the database relationships between categories. Hopefully the above error did not happen at a critical part of the copy categories function. This is when this error happens the most in the admin tool. If you see this error when copying categories go through your categories admin tool to see if any categories were missed in the procedure. You may need to delete and re-insert some categories or complete some parts of the "copy" manually. An error in the copy subcategory process can corrupt parts of the category tree. Manually go through categories to see if there are any problems. As an aside if you having to copy a large amount of categories that would cause such a problem we might suggest readjusting some of your thought processes in using SOOOO many categories obviously where MANY of them are exact copies from one branch of the category structure to another. Administering SOOO many categories can become an administrative nightmare. We would suggest the use of one of the various filters built into the software especially if "region/location" is part of the reason for such replication in categories.

Errors When Uploading Images

When uploading images memory is needed for components like the Geo script itself, any "background" php modules loaded, the GD image manipulation library, the uploaded image itself, working space for GD library to create the thumbnail and space for the thumbnail created. All of those components need to be in memory at one time making the image upload process the most memory sensitive process our software has.

You may say:

But it is only 2MB image, why does it take so much memory?!.

The "file size" is NOT the same as how much memory it takes to process the image. The file size might be just 2MB, but the IMAGE size (the size of the image when it is opened for processing) might actually be much larger once it is opened for processing. When the image is saved in a file, it is "compressed" to save room. When the script processes the image, it has to open it up "un-compressed" at the full image size. We found a little more technical explanation on this site that goes into more details.

Also note that if your server is a 64-bit server, it will need more memory than a 32-bit server, as 64-bit servers have a larger memory footprint than 32-bit servers.

Where the Error Appears

You may not always see this error in the browser. Your host/server may have turned off the display of PHP errors to the browser to slow down hacker. Some information about server paths on the server through errors. In these cases you may need to consult a PHP error log to find the specific error.

What Memory Limit Should Be

As far as what memory limit you should have there is no telling. We've seen our software work well in the default 8MB value that comes default. But most servers this is not sufficient. Almost ALL memory limit problems happen when uploading images. On some servers we have seen the 64MB is the first value that doesn't cause any problems when uploading images. Our first suggestion is 16MB then 32MB then 48MB and finally 64MB. Keep increasing the value until you no longer see the error when uploading images.

How and Where to Change the Memory Limit

The memory limit is a PHP environment variable set within the php.ini file. The php.ini file provides all of the configuration information PHP needs at start up. Many hosts allow you the ability to edit the php.ini file directly. Other hosts allow you to override some or all of the server wide php.ini values by inserting a php.ini file with the override values in your working directories. Still other hosts want complete control of this file and any changes to that file requires them to make those changes. As to which of the above situations happens with your host you will need to contact them to have the value changed.

tutorials/memory_errors/start.1240354696.txt.gz · Last modified: 2014/09/25 16:55 (external edit)