1

Suddenly my server got out of memory. I tried to check the disk space by using "df -k" command but it was looking fine. So after tracing lot of things I found httpd service is holding deleted files in temp memory, which can not be tacked by "df -k" To check last deleted files which are still with service, I used "sudo lsof | grep deleted" this command.

httpd 58324 58501 apache 8ur REG 253,0 0 279075355 /tmp/.ZendSem.SpCcXd (deleted)

enter image description here

This is a Magento application on centos7 (linux) server with apache 2.4.6 after spending some time I found, when stop apache and run "sudo lsof | grep deleted" this command I did not get any such issue. As soon as I start apache and check "sudo lsof | grep deleted" command, this again shows like attached screenshot.

2
  • I'd ask the person who wrote the app why it keeps holding deleted files open; this is not an apache question, it's someone doing stupid things in PHP.
    – tink
    Commented Oct 12, 2016 at 21:26
  • @tink It's Magento. Stupid things and bad code are included free of charge. Commented Oct 13, 2016 at 2:23

1 Answer 1

2

I've run into this issue with different applications on different platforms. It is a common coding problem where the code that uses files does not close the file when it is done with it. The code should always close the file when it has finished working with it.

One common method of securing temporary files is to open the file, delete it and then work with it. This may be what is being done here. However, the file remains in existence until it is closed.

A work around would be to limit the number of requests an Apache child will handle before shutting down. The files will be closed when the child exits. Setting MaxRequestsPerChild to somewhere in the range 100 to 1000 may mitigate the issue. The default value is 10000.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .