#23103 [Opn->Asn]: Memory Leak in DB/common.php
| From: | arnaud@php.net | Date: | Mon, 28 Apr 2003 08:57:43 +0000 |
| Subject: | #23103 [Opn->Asn]: Memory Leak in DB/common.php | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-15660@lists.php.net to get a copy of this message | ||
ID: 23103
Updated by: arnaud@php.net
Reported By: zukerman at math-hat dot com
-Status: Open
+Status: Assigned
Bug Type: PEAR related
Operating System: Linux
PHP Version: 4.3.1
Assigned To: lsmith
New Comment:
changing status
Previous Comments:
------------------------------------------------------------------------
[2003-04-07 17:36:14] zukerman at math-hat dot com
It looks like when DB_common::getOne() or DB_common::getRow() is
called, and no results are returned, the DB_Result object is never
free()ed. With pgsql this means that the row and num_rows arrays never
get cleared.
I came across this when my PHP scripts died with out-of-memory
exceptions.
This doesn't yet seem to be fixed in CVS. I think the simple fix is to
move the lines that free $res above the test of $err:
--- common.php.orig 2003-04-06 11:08:53.000000000 -0400
+++ common.php 2003-04-06 11:08:34.000000000 -0400
@@ -700,16 +700,16 @@
}
$err = $res->fetchInto($row, DB_FETCHMODE_ORDERED);
- if ($err !== DB_OK) {
- return $err;
- }
$res->free();
-
if (isset($sth)) {
$this->freeResult($sth);
}
+ if ($err !== DB_OK) {
+ return $err;
+ }
+
return $row[0];
}
@@ -764,15 +764,15 @@
$err = $res->fetchInto($row, $fetchmode);
- if ($err !== DB_OK) {
- return $err;
- }
$res->free();
-
if (isset($sth)) {
$this->freeResult($sth);
}
+ if ($err !== DB_OK) {
+ return $err;
+ }
+
return $row;
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23103&edit=1