I am getting this message:
Allowed memory size of 134217728 bytes exhausted (tried to allocate 10489856 bytes) in /home/MY_USER/public_html/application/views/ms/somefile.php
If I convert the sizes in megabytes it does not make sense because it will read as follows:
Allowed memory size of 138 Mega-bytes exhausted (tried to allocate 10.4 Mega-bytes) in /home/MY_USER/public_html/application/views/ms/somefile.php
so my script is exiting because it is trying to allocated 10.4 mega-bytes which is exceeding the allowed 138 mega-bytes?
I am totally lost here.
I already had my memory at 512MB but it is reporting it is being capped at 138MB. I have it set in the WHM for that specific PHP version.
Note: I am running in PHP-FPM setting.
2
Answers
The "tried to allocate" amount is how much you tried to add when exceeding the limit, not the total you tried to reach.
So this means that at the time of the error, you were already using between 128 and 138 MB, and you tried to allocate another 10.4 MB. 128+10.4 would be more than 138, so it exceeds the memory size limit.
Configuration
php.ini
,.htacces
,.user.ini
, or the php script itself viaini_set()
function.CLI
vsCGI
CGI and command line setupsIf your settings of
memory_limit
is set to 512M and your script fail to allocate 138M this sounds like your script is using different configuration than you have on the screenshot, see the CGI vs CLI above.Troubleshooting
Try to run
php_info()
within your php script/home/MY_USER/public_html/application/views/ms/somefile.php
to see what configuration is used by your script.Try to temporary set the more generous memory limit using
ini_set('memory_limit', '4096M');
within your../somefile.php
script.To get an idea how much memory your scrip needs you may print the final memory usage using PHP functions memory_get_usage()
echo memory_get_usage().' bytes.';
and/or memory_peak_usage()At the same time print the peak memory usage using
echo memory_peak_usage() .' bytes.';