Re: PHP Memory Leak

From: Date: Thu, 06 Dec 2007 23:49:15 +0000
Subject: Re: PHP Memory Leak
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-265534@lists.php.net to get a copy of this message
On Dec 6, 2007, at 3:15 PM, Sascha Braun <contact.saschabraun@web.de> wrote:
Hi Everybody, I have a couple of foreach loops which are ending in a for loop, which causes the apache to consume the complete memory of the server system the php engine is running on. The nesting level is at round about three and looking like that: $num_new = 4; if (is_array($array)) { foreach ($array as $key => value) Typo on above line?
{
       if ($value['element'] == 'test1') {
           foreach ($value['data'] as $skey => $svalue) {
               echo $svalue;
           }
       } elseif ($value['element'] == 'test2') {
           foreach ($value['data'] as $skey => $svalue) {
               echo $svalue;
           }
       }
       if ($num_new > 0) {
           // this part causes the memory leak
           for ($i = 0; $i < $num_new; $i++) {
               echo "sgasdgga";
           }
       }
} } I dont know if the above code is causing the memory leak the source is a little more complex, if nessessary I will provide some more code, Thank you! I hope for a solution --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#265534) next »