Page 1 of 1

Fatal error: Allowed memory size

Posted: Sat Jan 01, 2011 3:35 pm
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

Re: Fatal error: Allowed memory size

Posted: Sat Jan 01, 2011 4:06 pm
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

Re: Fatal error: Allowed memory size

Posted: Sat Jan 01, 2011 4:50 pm
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?

Re: Fatal error: Allowed memory size

Posted: Sat Jan 01, 2011 5:30 pm
by josh
You have a memory leak in your code, a bug that is your fault. Please type in paragraphs not double spaced lines.