Home > Archive > PHP Pear > March 2005 > DB_DataObject in a daemon
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
DB_DataObject in a daemon
|
|
| Trevan Devaun Richins 2005-03-24, 8:57 pm |
| 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
| |
| Alan Knowles 2005-03-26, 3:57 am |
|
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
| |
| Alan Knowles 2005-03-26, 3:57 am |
|
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
|
|
|
|
|