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
jmyeom
Forum Newbie
Posts: 8
Joined: Mon Jun 08, 2009 11:30 am

Fatal error: Allowed memory size

Post by jmyeom »

iive got the fatal error, allowed memory size limited reached,

this is odd, im not sure why, the code i am using is used to pull info from a forum, read whats inside the post, if theres a link, open it and save the text file

now, it hit the limit, so i uped it to 32m on the php file

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

no good, me, getting mad, was stupid and did this:

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

thinking that it will sort it self out, about 5 minutes later, after my pc had recovered, i am greeted with this:

Fatal error: Allowed memory size of 1047527424 bytes exhausted (tried to allocate 261900 bytes) in C:\wamp\www\scriptcheck.php on line 146

i mean, surly 1 gb memory is enough?

any ideas whats going on?

ive reset wamp, and nothing

any ideas is a big help :)

thanks
||jmyeom
anantha
Forum Commoner
Posts: 59
Joined: Thu Dec 23, 2010 7:38 pm

Re: Fatal error: Allowed memory size

Post by anantha »

one way to solve is to set the memory limit to -1..so the memory limit will not be enforced...that is what i could think of...the default value for memory limit is 128M
jmyeom
Forum Newbie
Posts: 8
Joined: Mon Jun 08, 2009 11:30 am

Re: Fatal error: Allowed memory size

Post by jmyeom »

so if i set it to -1, will it crash my pc like last time?

edit:, yes it will :P

just 100% cpu and my ram, moving to 50% of my pagefile


is there anyway of @optimizing@ my script?

so, the script reads line by line a file, this file is 500 lines long, for each line it reads, it gets the data, and opens a webpage depending whats on the list

it then removes unneeded stuff from the webpage using str_replace,

it then searchs whats inside for a keyword using stripos

if that keyword is found, (the keyword is a url), open that url

check to make sure the url we opened is the url we want, if it is, then same it to a file, else go back and check again for another keyword



all that uses the same variable, normall b2, b3 or newstr

is there away i can make sure it dont hit this memoryblock?

my script ran and did 98, and failed at the 99, now if i start it again at only 99, as in nothing else, only do that, it still fails,

99 is nothing special, its simpler then some of the others it has had to do, but it fails, any ideas?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Fatal error: Allowed memory size

Post by josh »

You have a memory leak in your code, a bug that is your fault. Please type in paragraphs not double spaced lines.
Post Reply