Mistaken Memory Limit: "Allowed memory size of X bytes exhausted"
Encountering the error "Allowed memory size of 67108864 bytes exhausted," despite phpinfo reporting a memory_limit of 128M, is not uncommon. Let's delve into the reasons behind this discrepancy.
PHP's configuration settings can be set in several locations:
PHPinfo displays the "Master" value as the default and the "Local" value as the active configuration. The active configuration can be overridden in any of the locations mentioned above.
Notably, PHP maintains separate .ini files for command-line and webserver operations. The memory limit reported by phpinfo() in a command-line context may differ from that reported in a web script.
In the specific instance, an ini_set() call in a primary php file, unbeknownst to the user, was modifying the memory limit, resulting in the error message despite the phpinfo reporting a higher value.
The above is the detailed content of Why Does PHP Report a Higher Memory Limit in phpinfo() Than the Actual Allowed Size?. For more information, please follow other related articles on the PHP Chinese website!