#1112 [NEW]: Memory Leak in Pear DB
| From: | bemis at docutronsystems dot com | Date: | Thu, 01 Apr 2004 16:10:43 +0000 |
| Subject: | #1112 [NEW]: Memory Leak in Pear DB | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-26935@lists.php.net to get a copy of this message | ||
From: bemis at docutronsystems dot com
Operating system: Fedora Core 1
PHP version: 4.3.4
PHP Bug Type: Bug System
Bug description: Memory Leak in Pear DB
Description:
------------
The row->free() function doesn't work when the Results are empty.
I wanted a basic daemon that selected every two seconds, and did an action
based upon the select results.
most of the time the select will return nothing.
I am finding that after two days of running this piece of my daemon my
computer is hanging.
I can rewrite this in c, but my whole project is in PHP so I wanted to use
PHP in case the project ever needs to be passed on.
Reproduce code:
---------------
#!/usr/bin/php -q
<?php
include 'DB.php';
$db_object = DB::connect('mysql://root:root@localhost/client_files',
TRUE);
$db_object->setFetchMode(DB_FETCHMODE_ASSOC);
while(true)
{
usleep(500000);//dont go crazy
$res=$db_object->query( "select doc_id from this_should_work where
doc_id=2" );
$row=$res->fetchRow();
//this is a dumbed down version, but does the memleak
$res->free();
unset($row);
unset($res);
echo memory_get_usage()."\n";
}
?>
Expected result:
----------------
I expect that the memory doesn't increase:
so I'd like to see the script output
502608
502608
502608
502608
502608
502608
502608
502608
502608
502608
502608
502608
502608
Actual result:
--------------
what I actually see is our script increasing at a rate of about 120 bytes
per loop:
502608
502784
502904
503024
503144
503264
503384
503504
503656
503776
503896
504016
504136
504256
504376
504496
504680
504800
--
Edit bug report at http://pear.php.net/bugs/bug.php?id=1112&edit=1
--