Home > Article > Backend Development > Why Does PHP's Memory Limit Differ Between CLI and Webserver?
Resolving "Allowed Memory Size of X Bytes Exhausted" Error
While investigating the error message "Fatal error: Allowed memory size of 67108864 bytes exhausted," one may notice a discrepancy between the memory limit reported by PHPEcho and the actual available memory. This is because PHP's configuration can be set in various locations, including:
In PHPInfo's output, the "Master" displayed value represents the default compiled memory limit, while the "Local" value reflects the actual active memory limit. This can be overridden in any of the aforementioned locations.
Furthermore, PHP differentiates between command-line and webserver-based operations. Running phpinfo() from the command-line may produce different memory limit values than when executed within a web-based script.
To resolve the memory exhaustion error, identify and modify the conflicting memory limit settings in the applicable configuration file(s) or PHP script(s). This can be determined by using the php -i | grep memory_limit command to display the CLI configuration.
The above is the detailed content of Why Does PHP's Memory Limit Differ Between CLI and Webserver?. For more information, please follow other related articles on the PHP Chinese website!