Increase the memory limit of PHP applications

Warning: increasing the maximum memory allowed for each PHP process reduces the application scalability because it decreases the number of concurrent PHP processes the server can run.
Solution #1

For web applications, open the php.ini configuration file used by your server and change the value of the memory_limit option:

memory_limit = 512M
Solution #2

If you can't edit the php.ini configuration, create a file called .htaccess in the project root directory and add the following:

php_value memory_limit 512M
Solution #3

For PHP scripts run on the command console, use the -d option to increase the memory limit just for that script execution:

# before
$ php my_script.php

# after
$ php -d memory_limit=512M my_script.php
Find more solutions about: , , , , ,