Allowed memory size of X bytes exhausted
PHP's config can be set in multiple places:
- master system
php.ini
(usually in /etc somewhere) - somewhere in Apache's configuration (httpd.conf or a per-site .conf file, via
php_value
) - CLI & CGI can have a different
php.ini
(use the commandphp -i | grep memory_limit
to check the CLI conf) - local .htaccess files (also
php_value
) - in-script (via
ini_set()
)
In PHPinfo's output, the "Master" value is the compiled-in default value, and the "Local" value is what's actually in effect. It can be either unchanged from the default, or overridden in any of the above locations.
Also note that PHP generally has different .ini files for command-line and webserver-based operation. Checking phpinfo()
from the command line will report different values than if you'd run it in a web-based script.
Meaning of Fatal error: Allowed memory size of x bytes exhausted (tried to allocate y bytes) ?
- It means that the memory used by the PHP script exceeded the value of the
memory_limit
configuration option. Note this may or may not agree with what the operating system thinks the memory usage of the script is at the time of the error. x
gives you the value of thememory_limit
configuration option. You can also assume that the server has at least enough virtual memory to handle the limit, but that's about it.- No,
y
is just the size of the straw that finally broke the camel's back.
PHP Allowed memory size of X bytes exhausted
You can reduce memory usage two other ways without increasing the memory limit...
- Consider setting $mpdf->simpleTables = true; if you do not need complex table borders, or $mpdf->packTableData = true; if you do not mind the extra processing time.
- packTableData – Use binary packing of table data to reduce memory usage
Both of which will increase processing time in order to save memory usage.
Allowed memory size php.ini
Try print phpinfo and check that these variables are actually updated or not. Also it might be your path issue or code error. Try check the permissions of the folder as well . It always does not seems to be a memory issue . You can check here that it can be you coding style , your query or any other scenario which is causing this issue Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)
Allowed memory size of 536870912 bytes exhausted in Laravel
You can try editing /etc/php5/fpm/php.ini:
; Old Limit
; memory_limit = 512M
; New Limit
memory_limit = 2048M
You may need to restart nginx
:
sudo systemctl restart nginx
You may also have an infinite loop somewhere. Can you post the code you're calling?
Symfony 5 cache:clear php.CRITICAL: Fatal error: Allowed memory size
It looks like the bin/console cache:clear
command takes up a lot of memory. I don't think it's because of the twig files.
setting up memory_limit=-1
is sort of you are disabling the memory limit, means giving unlimited of memory to run PHP. Please check your php.ini file and adjust the memory_limit.
Note that you might have 2 php.ini files for PHP, one for web and one for command-line use. Use php -i
to see the loaded ini file.
Use this command php -i | grep 'Configuration'
to grep the output from command line.
PHPExcel Allowed memory size of exhausted
If you cant increase memory limit try another libs
PHP-Export-Data by Eli Dickinson
simple excel
PHP_XLSXWriter
Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) Laravel
This means you need to also update your php.ini memory_limit
directive.
Try put in your php.ini :
memory_limit=1024M and restart apache :
sudo systemctl restart httpd.service
Related Topics
How Are Echo and Print Different in PHP
How to Show Multiple Recaptchas on a Single Page
PHP: Storing 'Objects' Inside the $_Session
PHP Foreach Pass by Reference: Last Element Duplicating (Bug)
How to Remove Array Element and Then Re-index Array
How to Detect Duplicate Values in PHP Array
Converting HTML to Plain Text in PHP For E-Mail
Save Image from Url With Curl PHP
"Smtp Error: Could Not Authenticate" in PHPmailer
How to Resolve Curl Error (7): Couldn't Connect to Host
Parsing Json Object in PHP Using Json_Decode
PHP Json_Decode() Returns Null With Valid Json
Check If JavaScript Is Enabled With PHP
How to Tell Which Button Was Clicked in a PHP Form Submit