memory_limit = 300M Fatal error: Allowed memory size ????

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ericsimard
Forum Newbie
Posts: 2
Joined: Thu May 15, 2008 7:00 pm

memory_limit = 300M Fatal error: Allowed memory size ????

Post by ericsimard »

Running windows 2003 server, apache2 and php 5.
memory_limit was 100M, but got this error when running a query against SQL server:

Fatal error: Allowed memory size of 314572800 bytes exhausted (tried to allocate 65536 bytes) in

As you can see got the memory size all the way up to 300M,
What is loosing me is that from 100 to 200 and finnaly 300M memory_limit,
(tried to allocate ...) was allways 65536 bytes.

Any idea why?

Apache got restarted every time.

I did not create the code behind this but it is using pattemplate and is quite old and badly programmed.
I could understand the script using more then a 100M cause by bad programming practice but not 300.
and the 65536 ..... ????
Hope someone can help put some light on this!
Thanks in advance
savadi
Forum Newbie
Posts: 4
Joined: Thu May 15, 2008 10:08 pm

Re: memory_limit = 300M Fatal error: Allowed memory size ????

Post by savadi »

Apache got restarted every time.
this means your terminating your php to solve the memory issues.

Most likely scenario
There is endless loop (for,while, do while) in the code.
The endless loop is assigning values to an array.
Since the endless keep assigning values to the array is keep getting bigger and bigger till it exhaust all the memory available.
Thats y the problem is still there, even tough you increased your memory limit.

If this is the case, try locate the endless loop.
Than again, I cant be 100% sure, becoz i dont have access to the code.

Good Luck!
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: memory_limit = 300M Fatal error: Allowed memory size ????

Post by VladSun »

ericsimard wrote:Fatal error: Allowed memory size of 314572800 bytes exhausted (tried to allocate 65536 bytes) in
That means that:
already_allocated_memory + 65536 > 314572800

Put some "memory-benchmark" lines inside your code and see what eats the memory.
There are 10 types of people in this world, those who understand binary and those who don't
ericsimard
Forum Newbie
Posts: 2
Joined: Thu May 15, 2008 7:00 pm

Re: memory_limit = 300M Fatal error: Allowed memory size ????

Post by ericsimard »

Thanks for the reply, ill look for the memory_benchmark.
The infinit loop is unlikely because it use to work fine,
database got bigger and now it doesnt work anymore.
ill do some test and post back with some result!
thanks!
Post Reply