Investigating "Allowed Memory Size Exhausted" Error
The error message "Allowed memory size of X bytes exhausted" indicates that PHP has attempted to allocate more memory than allowed. While PHPInfo suggests a memory limit of 128M, the error suggests a limit of only 64M. To investigate this discrepancy, it's important to understand PHP's configuration hierarchy.
PHP's configuration can be set in multiple locations:
In PHPInfo output, the "Master" value is the default and the "Local" value is what's in effect. The Local value may be overridden in any of the other locations.
Note that PHP has separate .ini files for command-line and webserver-based operation. Checking phpinfo() from the command line will show different values than from a web-based script.
In this case, the error is likely caused by an ini_set call in a primary PHP file. This call may have been added inadvertently and is overriding the global memory limit setting. To resolve the issue, locate the ini_set call and remove or modify it to ensure that it fits within the desired memory limit.
The above is the detailed content of Why is My PHP Script Showing 'Allowed Memory Size Exhausted' When phpinfo() Shows a Higher Limit?. For more information, please follow other related articles on the PHP Chinese website!