#23103 [Asn->Csd]: Memory Leak in DB/common.php

From: Date: Wed, 11 Jun 2003 17:08:14 +0000
Subject: #23103 [Asn->Csd]: Memory Leak in DB/common.php
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-17315@lists.php.net to get a copy of this message
ID: 23103 Updated by: cox@php.net Reported By: zukerman at math-hat dot com -Status: Assigned +Status: Closed Bug Type: PEAR related Operating System: Linux PHP Version: 4.3.1 Assigned To: ssb New Comment: This bug has been fixed in CVS. In case this was a PHP problem, snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. In case this was a documentation problem, the fix will show up soon at http://www.php.net/manual/. In case this was a PHP.net website problem, the change will show up on the PHP.net site and on the mirror sites in short time. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2003-05-04 12:26:58] lsmith@php.net This is also related to http://bugs.php.net/bug.php?id=18494 ------------------------------------------------------------------------ [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

« previous php.pear.dev (#17315) next »