From:             
Operating system: WinXP SP3
PHP version:      5.3.2
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:Memory leak in infinite loop

Description:
------------
Run PHP script with infinite loop from command line. Call each loop
database function from extension (I tested SQLite and Mysqli). Open task
manager. You will see that memory use is growing up, while PHP function
memory_get_usege() reports that memory usage is constant. The memory usage
may grow up to 1,5Gb or even more (depends on script code size), even if
memory_limit is set to 8Mb.



How is this possible?!

Test script:
---------------
<?php



$dbfile = 'mysqlitedb.db';

if(file_exists($dbfile)) unlink($dbfile);

$db = new SQLite3($dbfile);



$db->exec('CREATE TABLE foo (id INTEGER, bar varchar(30))');



$db->exec("INSERT INTO foo (id, bar) VALUES (1, 'This is a test')");



$i=0;

while(1)

{

        $i++;

        $db->exec("INSERT INTO foo (id, bar) VALUES ($i, 'This is a test')");

        $db->exec("UPDATE foo SET bar='This is memory leak' WHERE id=$i");



        echo "$i ".memory_get_usage()." ".memory_get_usage(true)."\r";

}



?>



Expected result:
----------------
Constant memory usage.

Actual result:
--------------
Memory usage grown up (script output):



iteration, memory_get_usage(), memory_get_usage(true), memory usage(from
taskmgr), virtual memory usage(from taskmgr)



2131 330384 524288 - 1068Kb 5356Kb

4661 330384 524288 - 1148Kb 5440Kb

10974 330384 524288 - 1336Kb 5652Kb

24985 330384 524288 - 1824Kb 6140Kb

43894 330384 524288 - 2516Kb 6828Kb



As you can see, memory usage is not constant. Why?!

-- 
Edit bug report at http://bugs.php.net/bug.php?id=51648&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=51648&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=51648&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=51648&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=51648&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=51648&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=51648&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=51648&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=51648&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=51648&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=51648&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=51648&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=51648&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=51648&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=51648&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51648&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51648&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=51648&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=51648&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=51648&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=51648&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=51648&r=mysqlcfg

Reply via email to