User Tools

Site Tools


Sidebar

tutorials:memory_errors:start

PHP Memory Limit Errors

This error most often happens when clients of your site 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, 16MB, 24MB or 32MB (most recently). 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 ####

Memory usage by the script will only increase with time as we try to ever decrease page load times within the software. We try to preserve memory usage as much as possible in the software, but there are parts of the software where more memory improves page load times. For instance, when the software gets the title of a listing for the SEO addon to display the title in the URL, it saves the title in the memory so that any other links on the page for that same listing don't have to get the same data from the database. These types of improvements decrease page load times and decrease the load on the database, but the trade-off is more memory usage. A typical page load on the default front page, with all it's modules and addon tags being loaded, may have a "peak" memory usage of 24MB as reported by PHP. That may sound ok and under any limits set in php but that does not include any "overhead" used by Apache itself. Our software isn't the only one using that memory and there's no way for us to know what your host loads into memory along with our script. The amount of memory used by the host is completely dependent on their configuration and differs from host to host depending on their needs. Also note that different pages in the software require different memory needs than others. We explain some of those situations within this page to better illustrate the issue.

Errors within the Geographic Setup and Geographic Navigation Addon Regions Admin Tools

We've seen this appear to more clients with the release of v6. This page loads all regions within the system to make the admin tool a lot easier to use. This means that more memory is used to create the page in the first place thus the increase in memory limit errors.

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. If you still need to copy categories try copying smaller amounts of categories at one and/or increasing the allowed memory within the php.ini file.

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.

When using the Oodle or RSS feed features

You see a memory limit error when using the Oodle or RSS feeds usually because you are trying to display too many listings through that feed for the amount of memory you have allocated to display it in. You can either do one of two things here. You can lower the number of listings you do try to display through those feeds to a point where you no longer see the error or you can increase the memory limit in php to a high enough limit to allow you to display all the listings you want to display through those feeds. One thing to check though is the receiver of the feed. Do they have a limit to how many listings they will receive through a feed? If they do you will need to set the listing limit and then the memory limit if errors occur at that listing count level. Think through this one a bit. If you have 100,000 ads do you think the recipient will handle/import all those listings at once or at all? Question the recipient and see what their wishes are. If your feed is too big they may ignore it or only take the first 100 (or 500 or 10,000) no matter what you send to them.

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 some default 32M configurations. But for most servers this is not sufficient. Almost ALL memory limit problems happen when uploading images. Our first suggestion is 72M or above. At those values we've seen almost no reports of issues. If you see memory limit issues above 72M (128M or 256M) this should be reported to support for a possible closer examination. 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 the host to have the value changed.

Changing the php.ini file is not something Geo support can do, it is essentially a server setting and therefore you need to contact your host if you are not sure how to change it.

tutorials/memory_errors/start.txt · Last modified: 2015/06/02 14:30 by geojames