Home > Article > Backend Development > Why does PHP's "Allowed Memory Size" error message show a different value than the reported "memory_limit" in phpinfo()?
Troubleshoot "Allowed Memory Size of X Bytes Exhausted" Error
When PHP encounters an error stating "Allowed memory size of X bytes exhausted," it indicates that the allocated memory has reached its limit. Typically, you may check PHPInfo and notice that the reported memory_limit is considerably higher than the value mentioned in the error message. This discrepancy can be attributed to PHP's multiple configuration sources.
Configuration Sources:
PHP's configuration can be set through various channels:
PHPInfo Output:
In PHPInfo's output, the "Master" value represents the default value compiled during PHP installation. The "Local" value, however, reflects the actual effective configuration. This value may match the default or be customized in any of the aforementioned locations.
CLI vs. Webserver:
Furthermore, PHP uses separate .ini files for command-line (CLI) and webserver operations. PHPInfo generates different values depending on whether it is accessed via the command line or a web-based script.
Troubleshooting:
The above is the detailed content of Why does PHP's "Allowed Memory Size" error message show a different value than the reported "memory_limit" in phpinfo()?. For more information, please follow other related articles on the PHP Chinese website!