1

We are running Ubuntu 16.04 LTS with Apache 2.4 and PHP 7.2. 9 times out of 10, the web app works well, but at a random interval, we come across this error message.

"Allowed memory of 134217728 bytes exhausted(tried to allocate 135168 bytes) in {file} line ..."

We are testing this on a staging server which is only used for a few of us - so the memory/CPU utilisation is a bare minimum.

One thing to note is that we only get this issue when we try to access content from outside the network via these PHP functions

  • file_get_contents

  • get_headers

Restarting apache fixes the issue but it comes back again very very randomly - sometimes immediately and other times in 1 day.

We tried increasing the PHP memory limit but that didn't help. This file_get_contents fails even for very very small files.

We have the same setup on our local machines (Win & Mac) and the web app works perfectly fine and we never hit these memory issues.

Any clue what could be going on or where should we look next? Could it be missing Apache Modules?

Thanks for your help in advance!

Sunil Shenoy
  • 111
  • 3
  • Did you try doubling the memory_limit? Also another data point you can gather is to use `memory_get_usage()` before and after each `file_get_contents`. This way you will be able to see what is going on. – Tux_DEV_NULL Jan 14 '19 at 12:12
  • I did try doubling the memory_limit. That did not help much. The error only delayed. We have added memory_get_usage() now and are monitoring. – Sunil Shenoy Jan 16 '19 at 07:45

0 Answers0