How do I increase the memory allocation for my PHP script?


If you need to increase the memory allocation for your script, you can create php.ini and .htaccess files in the subdirectory the script is in.

For example, if you want to increase the memory limit for your script to 128MB:

  1. Create a php.ini file with:

memory_limit = 128M;

  1. Create an .htaccess file with:

RLimitMEM MAX

  1. Upload both to the subdirectory the script is in

If the script still does not work, pay attention to the error message that has been produced.  If it is still reporting the same amount of memory, it is likely that the PHP memory is being set elsewhere, either within your code or via another php.ini.  Find where the memory limit is being set, and change it there.

If it is still saying it is out of memory after you have increased the memory, increase the memory again.  If it keeps producing memory errors at each level, it is likely that you have created an infinite loop, and it will keep running out of memory no matter how much you allocate to it.  You will need to examine the code and change it accordingly.



Article ID: 424
Created On: Mon, Mar 16, 2015 at 3:38 PM
Last Updated On: Sun, Oct 9, 2022 at 6:21 PM

Online URL: https://www.heartinternet.uk/support/article/how-do-i-increase-the-memory-allocation-for-my-php-script.html