Re: DB_DataObject in a daemon
| From: | Alan Knowles | Date: | Sat, 26 Mar 2005 03:07:46 +0000 |
| Subject: | Re: DB_DataObject in a daemon | ||
| References: | 1 | Groups: | php.pear.general php.pear.general |
| Request: | Send a blank email to pear-general+get-18350@lists.php.net to get a copy of this message | ||
try turning the overload off, that has been known to cause leaks. -
otherwise you should be OK, I've done quite a bit of testing to try and
fix this, although each release seems to introduce potential issues.
There is a script in CVS under tests, I think, that does memory testing
on large numbers of inserts.
Regards
Alan
On Thu, 2005-03-24 at 12:33 -0700, Trevan Devaun Richins wrote:
> We have a script that is running as a daemon and uses DB_DataObject.
> After the daemon has been running for a few days, we get an out of
> memory error in PHP. I have been trying to track down what could
> possibly be causing the memory leaks. I have called free on all the
> DO's and then unset them and made them null. I have also tried to clear
> all the globals that PEAR and DB_DataObject is using. I was just
> wondering if any of you have any ideas on what could be causing the
> memory leak.
>
> This is the main loop that is running most of the time as it waits for
> changes:
>
> while (1 && $ready) {
>
>
> $db = DB_DataObject::factory('updateall');
> $db->query($status_sql);
> $db->fetch();
>
> $current_time = date('Y-m-d H:i:s');
>
>
> $update = old_update($db->Rows, $db->Update_time);
>
> // if there has been a change, go do it
>
> if ($update) {
> // print out the date we were run (for logging purposes)
> echo get_time($current_time, true). " - Starting update
> script...\n";
> $result = main_updateall_loop();
> // if $result isn't true, we have an error
> if ($result !== true) {
> $result->writeLog();
>
> if ($result->getLevel() === UA_CRITICAL) {
> // critical error, lets leave
> ob_end_flush();
> exit();
> }
> }
> } else {
> $time = get_time($current_time);
> // if there is something to print, appendMessage
> if ($time != '') {
> echo $time ." - No updates to make\n";
> }
> }
> // just make sure it is all out there
> while (ob_get_level() > 0) {
> ob_end_flush();
> }
>
>
> // we've got to free up some memory
> $db->free();
> unset($db);
> $db = null;
>
> // used by PEAR that is never cleared
> unset($_PEAR_destructor_object_list);
> $_PEAR_destructor_object_list = null;
>
> unset($GLOBALS['_DB_DATAOBJECT']);
> $GLOBALS['_DB_DATAOBJECT'] = null;
> sleep(1);
> }
>
> As you can see the only thing that is created in this loop is a
> DB_DataObject. This loop is run 80% of the time (it only goes on if the
> Database was changed which is pretty rare).
>
> If you have any ideas, I would appreciate them.
>
> Trevan
>
> --
> Trevan Richins
> Computer Science Dep.
> System Admin