2.20.8. Fatal error: Allowed memory size
Error "Fatal error: Allowed memory size"Means that the script exceeded the PHP parameter value during its operation memory_limit current tariff plan.
Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes) in /home/example/example.com/www/path/to/script.php on line Z
X- available memory size, specified by the PHP parameter memory_limit, in bytes.
Y- the amount of memory that the script tried to use in excess of the available amount at the time of the error, in bytes.
/home/example/example.com/www/path/to/script.php- full path to the script, during the execution of which an error occurred.
Z- line number in the script where the error occurred.
Yis not required value memory_limit, insofar as
Yshows the amount of memory that was not enough at the time of the abnormal termination of the script, and in the case of further work, the script may require a much larger amount of memory.
Most often, the error occurs in the following situations:
- The most common situation in which a script runs out of all available memory is working with images. PNG and JPG formats compress the image, but PHP loads it into memory pixel by pixel to work with it, as if it were saved in BMP format. This results in the script running out of memory to process the image. To avoid an error, you should reduce the size of images before uploading them to the site and do not rely on the fact that PHP itself will change the format of images in high resolution.
- Executing database queries that return too large amounts of information that do not fit into available memory.
- Processing large XML files.
- Launching resource-intensive or just unoptimized scripts and modules.
The solution to the problem might be:
- If the site uses scripts of obsolete versions, be sure to check if the set for the site matches PHP version recommended by the site developer. If not, change it to the one you need and check the site in about 10-15 minutes.
- Reducing the size of the files processed by the script, analyzing the work and optimizing the script itself or the module in order to reduce its memory consumption.
- For archive rates with memory_limit 64 or 128 MB - using Turbo Boost can be temporarily (by 2 hours) increased memory_limit up to 256 MB. It is used for short-term exceeding of tariff plan restrictions when uploading goods to online stores, installing various themes and other resource-intensive tasks.
xxx - value memory_limit tariff plan.