Memery Allocation Error

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
abul
Forum Newbie
Posts: 1
Joined: Sat May 02, 2009 1:01 am

Memery Allocation Error

Post by abul »

Fatal error: Out of memory (allocated 786432) (tried to allocate 1572864 bytes) in student.php on line 1015

This is the Error notification i am encountering while i execute the scripts.Please provide me the solutions for clearing this error.I want to know what the function that takes place while i reduce and increase the memory limit.Explain me the functionality in Detail.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Memery Allocation Error

Post by Benjamin »

:arrow: Moved to PHP - Code

Have you tried searching for information regarding the memory limit of PHP?
Cirdan
Forum Contributor
Posts: 144
Joined: Sat Nov 01, 2008 3:20 pm

Re: Memery Allocation Error

Post by Cirdan »

I had this problem before. I fixed it by quoting a variable when using it inside the key part of an array. No idea why this fixed it

From: $array[$variable]
To: $array["$variable"]
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Memery Allocation Error

Post by pickle »

This is likely caused by an infinite loop, or you're processing a REALLY big object/array, or doing something in GD with a large image.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
ldougherty
Forum Contributor
Posts: 103
Joined: Sun May 03, 2009 11:39 am

Re: Memery Allocation Error

Post by ldougherty »

The error means that your script has exceeded the amount of memory allocated to php.

In your php.ini you will find this line

memory_limit = 8M

The configuration I've shown is for 8MB, if i am doing the math correct yours is 768KB

You will need to adjust this or you can attempt to do so via your code by using the following line at the top of your code.

ini_set('memory_limit', '8M');

Hope this helps.
Post Reply