Memory Allocation Error. Create a custom php.ini for PHP 5.2

Some programs produce errors in which it says the memory allocation is limited to 32MB and that you've exceeded the maximum allotted memory.

By default on the server the maximum amount of memory allocated to each file is 32MB. This helps stop the server from running away with a script and locking up (crashing) the server.

If you require more allocation, the error code will tell you how much more it needs - usually it's only a few killobytes, however you'll want to round this number up to the nearest megabyte. Here's an example error (truncated of course to eliminate customer details)

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 3840 bytes) in ...

While the error sounds like it had 32MB (33554432 bytes = 32MB) allocated and only tried to use a few bytes, it actualy means that it tried to use MORE than the 32MB allocated. In this case, it tried to use 3840 bytes more.

So if the number listed is lower than 1,048,576, just add one megabyte. Between 1,048,576 and 2,097,152 would be two megabytes and so on.

You can create a custom php.ini file within your site and upload it to the folder where you have installed your script. In the file place the following line:

memory_limit=35M

This will increase the memory limit from 32MB to 35MB. If you require more, increase the size. Please do not increase it to some large number such as 50MB or 200MB as this only defeats the purpose of trying to keep your site online without crashing.

All SHARED Hosting customers are limited to a maximum execution of between 110MB and 120MB. This is a system limit. If you have any questions regarding the memory limits or regarding a custom php.ini file, or require more than 100MB of memory allocation for the script to run, please open a support ticket at http://billing.handsonwebhosting.com for further assistance.

Also, please note that if you were using ionCube, you will need to add it's lines back into your new php.ini. If you were using Zend you may need to add php.ini lines as well.

If your scripts require Zend, IonCube or PDO_SQL, we recommend not only adding the additional memory setting, but also inserting the commands for Zend, IonCube and PDO_SQL too so that they work;

memory_limit = 35M
[Zend] 
zend_extension="/usr/local/IonCube/ioncube_loader_lin_5.2.so" 
zend_extension_ts="/usr/local/IonCube/ioncube_loader_lin_5.2_ts.so" 
zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.0 
zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.0 
zend_optimizer.version=3.3.0 
extension=pdo.so
extension=pdo_sqlite.so 
extension=sqlite.so
extension=pdo_mysql.so 
zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so 
zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so

Was this answer helpful?

Related Articles

PHP-based Form Mail (Feedback) Script

Updatedhttps://www.domainindia.org/login/knowledgebase/116/PHP-sendmail-Settings.html

Perl-based Form Mail (Feedback) Script

 Perl-based Form Mail (Feedback) ScriptUsing a Perl script you may accept feedback from your...

Feedback Form Code / Instructions

Feedback Form Code / InstructionsThe source code for the two files (feedback.php and feedout.php)...

PHP sendmail Settings

Using phpMailer to Send Mail through PHP Download the PHPMailer script First, download...

301 Redirect from non-www to ww -- Without Looping!

o - you want to improve your search engine rankings, and SEO gurus told you that Google might be...