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

ajay01's avatar

Production server frequently facing memory issue.

On my production server, I'm frequently facing memory problem. apache error log frequently logging this error.

856685.751702] Out of memory: Kill process 29946 (httpd) score 12 or sacrifice child
[856685.757737] Killed process 29946 (httpd) total-vm:585720kB, anon-rss:25324kB, file-rss:0kB, shmem-rss:72kB

In the Laravel Log file, I have this error is logging frequently.

[2021-01-29 07:10:45] local.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Out of memory (allocated 14680064) (tried to allocate 1052672 bytes) in /var/www/html/instacutportal/vendor/guzzlehttp/psr7/src/Stream.php:228
Stack trace:

I have some questions.

  1. Suppose somebody is using the system, they're logged in and doing stuff. When they're done, they close the browser tab without logging out. How does the server respond and release resources? Dose laravel handles it by itself?

  2. I have a file uploading feature where users can upload 200+ images, I'm storing it on an S3 bucket. The images are pass through the application server. dose there is some stage of an upload process where images or (parts of them at least) are stays in application server memory. Which seemed like it might be relevant for out of memory errors. in nutshell dose it store locally first?

0 likes
1 reply
ftiersch's avatar

PHP has memory on a "per request" basis... So just because your user is logged in and does stuff doesn't mean he / she is piling on memory because the garbage collector usually cleans it up in between. Same with images - while uploading they will be saved on the hard disk but you might have them in memory if you do other stuff for a short time (like resizing etc).

I've had a similar problem and saw that there is a php option if you are using php-fpm. See this thread: https://stackoverflow.com/questions/29608292/what-is-pm-max-children-and-pm-max-requests

Basically it says after how many requests a PHP process should be killed (and restarted) which would free up all the memory. I didn't have a value there so it would just sloooowly creep up bit by bit until it crashed. Currently I have a value of 500 in there (i think).

Please or to participate in this conversation.