5

I'm seeing this error in my production server, sometimes (I mean, it seems random, as my site as a decent traffic and so far it just happened 5 times):

[21-Feb-2012 23:43:19 UTC] PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 261900 bytes) in /home/xxxxx/xxxxx/xxx.php on line 1811

The funny part is, the file has only 798 lines, and this never happened before to me.
It may have to do with recent changes I made to my scripts, yes, but this error simply doesn't make sense to me.

Please keep in mind that I know what "Allowed memory size exhausted" error means, and I know how to increase the memory limit.
However, my question here is, why is PHP referring to a line that doesn't exist?
I don't know how to fix this problem, because this makes no sense to me.

Thank you.

17
  • Maybe its including a file and that file is failing. And also the server might be doing something like an autoload or something of the sort. Commented Feb 22, 2012 at 0:23
  • Was the old /home/xxxxx/xxxxx/xxx.php longer and do you have some sort of opcode cache? Commented Feb 22, 2012 at 0:23
  • It would help if we could see a little of the code from the file in question. Commented Feb 22, 2012 at 0:33
  • @jakx - It's including many files. What do you mean with "failing"? If the memory problem was on that included file, it would make sense the error to refer to that file, am I right? And what do you mean with "autoload"? Commented Feb 22, 2012 at 0:35
  • Long shot: Check the modified date on that particular file to see if it's been altered Commented Feb 22, 2012 at 0:35

1 Answer 1

4

I've just found what was causing this memory leak.

It was a recent change that was entering in recursion cycle between two functions, although it was a rare event.

The line 1811 is real, yes, but the file that the error was referring is not correct. The line 1811 was from another file (included on that referred one) where one of the functions is.

I still appreciate the help from the people who commented above.

Sign up to request clarification or add additional context in comments.

2 Comments

Just had the same thing. In my case, lib A calls lib B (recursively, till it runs out of memory, which was the bug). But PHP reported the memory error using the line number from lib A, but the file path to lib B (which doesn't have that many lines). Very confusing. Thanks for your tip.
I'm very glad this was helpful to you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.