#23103 [Asn]: Memory Leak in DB/common.php
| From: | lsmith@php.net | Date: | Sun, 04 May 2003 17:26:58 +0000 |
| Subject: | #23103 [Asn]: Memory Leak in DB/common.php | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-15838@lists.php.net to get a copy of this message | ||
ID: 23103
Updated by: lsmith@php.net
Reported By: zukerman at math-hat dot com
Status: Assigned
Bug Type: PEAR related
Operating System: Linux
PHP Version: 4.3.1
-Assigned To: lsmith
+Assigned To: ssb
New Comment:
This is also related to http://bugs.php.net/bug.php?id=18494
Previous Comments:
------------------------------------------------------------------------
[2003-04-28 03:57:42] arnaud@php.net
changing status
------------------------------------------------------------------------
[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