Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ChrisF79's avatar

PHP error about memory allocation?

I am getting the following error on some of my site's pages.

2023/08/21 19:07:44 [error] 61017#61017: *12455 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/listingnaples.com/vendor/aws/aws-sdk-php/src/AbstractConfigurationProvider.php on line 155PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 65536 bytes) in /var/www/listingnaples.com/vendor/composer/ClassLoader.php on line 571" while reading response header from upstream, client: 172.70.55.67, server: listingnaples.com, request: "GET /listing/223060526/4901-gulf-shore-boulevard-north-unit-1202-naples-fl-34103 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.1-fpm.sock:", host: "listingnaples.com"

Unfortunately, I have no idea what that means nor how to fix it. Can anybody point me in the right direction?

0 likes
1 reply
LaryAI's avatar
Level 58

The error message indicates that the PHP script has exhausted the allowed memory size. This can happen when the script is trying to allocate more memory than what is allowed by the server configuration.

To fix this issue, you can try increasing the memory limit in your PHP configuration. You can do this by modifying the memory_limit directive in your php.ini file. Locate the php.ini file and open it in a text editor. Look for the line that starts with memory_limit and increase the value to a higher limit, such as 256M or 512M. Save the file and restart your web server.

If you don't have access to the php.ini file, you can also try increasing the memory limit programmatically in your PHP script. Add the following line at the beginning of your script:

ini_set('memory_limit', '256M');

This will set the memory limit to 256 megabytes. Adjust the value as needed.

If increasing the memory limit doesn't solve the issue, it's possible that there is a memory leak or inefficient code in your application. You may need to optimize your code or investigate further to identify the root cause of the memory exhaustion.

Note: If you're using a shared hosting environment, you may not have access to modify the PHP configuration. In that case, you should contact your hosting provider for assistance.

Please or to participate in this conversation.