Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal error: Allowed memory size in PHP when allocating less

Tags:

php

memory

I'm getting this:

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 4981690 bytes) in...

That seems a bit odd! From what I can read, it shouldn't happen should it? Isn't meant' to be the other way around. I'm already using a stupidly large memory_limit

like image 615
David Avatar asked Feb 24 '12 14:02

David


People also ask

How do I fix PHP fatal error allowed memory size?

You can find the php. ini file in the public_html for your website and right-click on the file to Edit it. Look for the line defining the memory_limit variable and set the value accordingly. Then, save the changes and reload your site to see if the PHP “Allowed Memory Size of Bytes Exhausted” error has been resolved.

How do I fix fatal error allowed the memory size of 134217728 bytes exhausted?

The correct way is to edit your php. ini file. Edit memory_limit to your desire value. As from your question, 128M (which is the default limit) has been exceeded, so there is something seriously wrong with your code as it should not take that much.

How do I fix a fatal memory error?

This usually happens when hosting a high-traffic and big websites using small shared hosting servers, which allocate very little amounts of PHP memory per each hosting plan. To fix the error, you have to manually increase the default PHP memory limit set for your server.

What is the max memory limit for PHP?

The default memory limit is 256M and this is usually more than sufficient for most needs. If you need to raise this limit, you must create a phprc file.


1 Answers

It doesn't attempt to allocate it all at once. Let's say our limit is 10 bytes. It will allocate 3, 3, 3 and another 3 - boom: throws the error:

Allowed memory size of 10 bytes exhausted (tried to allocate 3 bytes) in..
like image 189
Wesley van Opdorp Avatar answered Sep 22 '22 16:09

Wesley van Opdorp