Page 1 of 1

Zend problem??!! or memory problem or just bad code?!

Posted: Fri Apr 21, 2006 5:08 am
by bertilpaiva
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I've got this error and i don+t know why, it seemsthat+s because of the function listed at the bottom:

Code: Select all

Fatal error: Allowed memory size of 8388608 bytes exhausted at /usr/ports/lang/php5/work/php-5.1.2/Zend/zend_hash.c:417

Code: Select all

function fillCalendar(){
        $y = $this->year + 0;
        $m = $this->month + 0;
        for ( ; $y < $y+2; $y++ )
          $this->yearsAvailable[]=$y;
        
        if ( $this->isBisixth )
            $extraDay=1;
        
        for ( ; $m < 12; $m++)
            $monthsLeft[] = $m;
    }
I've changed the memory_limit in php.ini file, and then the errors desapear but i get a blank page instead-- no html parsed!? :oops:
i'm loosing it 8O 8O


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Fri Apr 21, 2006 6:07 am
by shiznatix
bad code...

Code: Select all

$y = $this->year + 0;
$m = $this->month + 0;
for ( ; $y < $y+2; $y++ )
$this->yearsAvailable[]=$y;

if ( $this->isBisixth )
$extraDay=1;

for ( ; $m < 12; $m++)
$monthsLeft[] = $m;
}
first...

Code: Select all

$y = $this->year + 0;
$m = $this->month + 0;
what are you trying to do there? that does not make any sence at all to me.

second:

Code: Select all

for ( ; $y < $y+2; $y++ )
//and
for ( ; $m < 12; $m++)
where is the first part of those for loops? a regular for loop looks like this:

Code: Select all

for ($y=0; $y < 20; $y++ )//...
edit:
last (this is where your memory problem comes in!)

Code: Select all

for ($y=0; $y < $y+2; $y++ )
thats like saying "do this code while 2 is less than 2+2" well...2 is ALWAYS less than 2+2! that means it will loop for forever and thus eating up all your memory and never getting past that part.

fix your code and try it again

Posted: Fri Apr 21, 2006 7:11 am
by bertilpaiva
Thank you so much , i was sleeping when i wrote , well i am rookie after all!!
Thanks for having the trouble to respond to me!