#23103 [NEW]: Memory Leak in DB/common.php

From: Date: Mon, 07 Apr 2003 22:36:14 +0000
Subject: #23103 [NEW]: Memory Leak in DB/common.php
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-15004@lists.php.net to get a copy of this message
From: zukerman at math-hat dot com Operating system: Linux PHP version: 4.3.1 PHP Bug Type: PEAR related Bug description: Memory Leak in DB/common.php 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 bug report at http://bugs.php.net/?id=23103&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=23103&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=23103&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=23103&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=23103&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=23103&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=23103&r=support Expected behavior: http://bugs.php.net/fix.php?id=23103&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=23103&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=23103&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=23103&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23103&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=23103&r=dst IIS Stability: http://bugs.php.net/fix.php?id=23103&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=23103&r=gnused

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