Re: PHP4: php_module holds memory too long !

From: Date: Mon, 15 Jan 2001 20:13:28 +0000
Subject: Re: PHP4: php_module holds memory too long !
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-44159@lists.php.net to get a copy of this message
I know, you are bored with me, but this is continuation... Here I give some examples, when the memory occupation occures. 1. The first script goes OK: <?php echo "<HTML><BODY>"; echo "Time:".time()."<BR>"; for ($i=0; $i<150000; $i++) { $TAB1['a'.$i]='tekst'.$i; $TAB2['a'.$i]='tekst'.$i; $TAB3['a'.$i]='tekst'.$i; $TAB4['a'.$i]='tekst'.$i; } echo "Finished"; echo "</BODY></HTML>"; ?> After execution memory goes back to system. 2. Here you have two skripts, when it occures: example a) <?php echo "<HTML><BODY>"; echo "Time:".time()."<BR>"; for ($i=0; $i<150000; $i++) { $TAB1['a']='tekst1'.$i; $TAB1['b']='tekst2'.$i; $TAB_M[$i]=$TAB1; } echo "Finished"; echo "</BODY></HTML>"; ?> 60M hangs... example b) <?php echo "<HTML><BODY>"; echo "Time:".time()."<BR>"; for ($i=0; $i<1000; $i++) { $TAB1['a'.$i]='tekst1'.$i; $TAB1['b'.$i]='tekst2'.$i; $TAB_M[$i]=$TAB1; } echo "Finished"; echo "</BODY></HTML>"; ?> 60M hangs again... Only killing the httpd process helps. So, as you see, httpd has problems with freeing memory when we keep arrays as elements of other arrays. And as I said before, there are no problems, when we use the method of replacing functions in Zend/zend_alloc.* source files. I've tested it on two different hosts, with two different php configurations. There's also a second problem, very related: even when the memory is released properly, it happens only _after_ the client gets _all_ the data. It is easy to imagine slow clients, which block unproduseably large amounts of memory. When result of execution is short, it is not noticable (whole result fits in some buffers, I dont know at which level). It apperares when the result overgrows 100 kb (on my host). Is there any buffer in php module (or httpd), in which might the result be stored ? Can we change the size of this buffer ? And what moment is memory cleared at ? Here is a sort script, which I tested: Here is an example script: <?php echo "<HTML><BODY>"; echo "Time:".time()."<BR>"; //Memory allocation for ($i=0; $i<1000; $i++) { $TAB1['a'.$i]='tekst1'.$i; $TAB1['b'.$i]='tekst2'.$i; $TAB_M[$i]=$TAB1; } //Long result for ($i=0; $i<150000; $i++) { echo "a"; } echo "Finished"; echo "</BODY></HTML>"; ?> Filip Sielimowicz (sorry for my ingleesh...)

« previous php.dev (#44159) next »