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

  • 48

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:


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 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

Was this answer helpful?
« Back