1

I'm getting this and I'm not sure why?

[21-Feb-2015 01:10:43 UTC] PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 32 bytes) in /home/vcasts/public_html/ajax.php on line 30

Line 30 is..

$users[] = rtrim( fgets( $fp, 32 ) );

Help anyone?

5
  • 6
    That line isn't the problem by itself, it's just the straw that broke the camel's back. Your script is loading too much data into memory, you need to figure out why. Commented Feb 21, 2015 at 1:24
  • possible duplicate of Reference - What does this error mean in PHP? Commented Feb 21, 2015 at 1:25
  • Can I fix it or not? Commented Feb 21, 2015 at 1:26
  • 2
    Yes, you can. Commented Feb 21, 2015 at 1:28
  • use less or allocate more. there's no third option Commented Feb 21, 2015 at 1:30

2 Answers 2

1

The error is telling you "Allowed memory size of 536870912 bytes exhausted" - you ran out of memory. It's not necessarily this line of code that's the problem, but you have one or more memory hogs somewhere in your app using up about 500MB.

This line just happens to be the one that caused you to exceed the limit.

Refer to this reference answer for how to investigate and fix errors like this.

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

Comments

0

If it happens just by running code without any changes done recently, it might be due to the fact that you storing too much data in $_SESSION. Try destroy $_SESSION (session_destroy();) to see if it helps and if so fix the code so that $_SESSION stores only data that are necessary or the code deletes them when not needed.

Comments

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.