Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.11.5

Bug #13652 memory leak
Submitted: 2008-04-11 13:43 UTC
From: nahuel Assigned:
Status: Bogus Package: DB_DataObject (version 1.8.8)
PHP Version: 5.2.4 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2008-04-11 13:43 UTC] nahuel (Nahuel Angelinetti)
Description: ------------ it exist a memory leak using mdb2 driver with db_dataobject. Using singleton design pattern. I use this, in a shell script writed in php. this is not solved using ->free(); Test script: --------------- I create an object that have a db_dataobject object, when I unset/null my object, the memory doesn't go down. Expected result: ---------------- The same memory usage than before object creation should be expected after the destruction. Actual result: -------------- Allowed memory size of 16777216 bytes exhausted (tried to allocate 6245 bytes)

Comments

 [2008-04-14 01:14 UTC] nahuel (Nahuel Angelinetti)
I have more information from it : print_r("=============>"); print_r($this->_Tdb); $this->_Tdb->free(); print_r("=============>"); print_r($this->_Tdb); will print this : =============>DataObjects_List Object ( [__table] => list [id] => 272 [name] => myname [_DB_DataObject_version] => 1.8.8 [N] => 1 [_database_dsn] => [_database_dsn_md5] => 5678f7a9afce314fbc8263ec8ea6c43c [_database] => db1 [_query] => [_DB_resultid] => 15 [_resultFields] => [_link_loaded] => [_join] => [_lastError] => ) =============>DataObjects_List Object ( [__table] => list [id] => 272 [name] => myname [_DB_DataObject_version] => 1.8.8 [N] => 1 [_database_dsn] => [_database_dsn_md5] => 5678f7a9afce314fbc8263ec8ea6c43c [_database] => db1 [_query] => [_DB_resultid] => 15 [_resultFields] => [_link_loaded] => [_join] => [_lastError] => ) so it generate looping error, that generate too much data in memory. The error is that I can't make two queries on the same object, but i make a free and it doesn't clean. Any idea ?
 [2008-04-14 01:48 UTC] nahuel (Nahuel Angelinetti)
commenting the if at the line 392 resolve the problem. I think it does not get the case of a "->get()" after a ->find();
 [2008-04-17 14:07 UTC] doconnor (Daniel O'Connor)
Nahuel, can you provide a small test case for this bug please?
 [2008-04-17 14:44 UTC] nahuel (Nahuel Angelinetti)
Not easy to provide something. I think we can do something like : <?php $db =& DB_DataObject::factory("myTable"); $db->myfield = "myvalue"; $rownb = $db->find(); $db->free(); $db->get('2); print_r($db); There is an error that say two request cannot be done on the same object. ?>
 [2008-04-17 16:12 UTC] hedge (Bechara Hitti)
We are experiencing the same issue. However we have noticed the following: 1) The error does not occur if the object is created without calling ->insert() and ... 2) using ->link() at the same time. 3) If two instances of the script are launched at the same time, they will both insert the same number of record (failure in our case if occurring at 10922 and two scripts insert double that number exactly even though they are launched at the same time). 4) The error in our case is returning: Glibc detected ... After setting MALLOC_CHECK_=0 The error became: Segmentation Fault Hope this helps, Hedge
 [2008-04-17 23:31 UTC] alan_k (Alan Knowles)
ok can you * call free() after finishing a transaction. * be carefull if using get->link() - it may not do any free'ing.. - in which case you may manually have to modify the $GLOBALS[DB_DATAOBJECT] array to free any extra data. * do not re-use objects * check the size of $GLOBALS[DB_DATAOBJECT] at various stages of the application to see if it's growing. What free does is call a method in the DB library that cleans up records of insert id's. along with clearing a few cache results. If you are getting segfaults you need to find the page on www.php.net that describes doing gdb backtraces.
 [2008-09-17 23:36 UTC] alan_k (Alan Knowles)
use clone() before doing the query rather than doing multiple queries on a single object.