Re: DB getAll method has memory leaks

From: Date: Fri, 27 Sep 2002 17:04:47 +0000
Subject: Re: DB getAll method has memory leaks
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-9617@lists.php.net to get a copy of this message
2. In mysql.php in the simpleQuery method (which getAll uses) there is this bit of code: if (is_resource($result)) {
    $numrows = $this->numrows($result);
    if (is_object($numrows)) {
        return $numrows;
    }
    $this->num_rows[$result] = $numrows;
Here is my suggested patch for this problem. Instead of making num_rows an array just make it a regular variable. That way it doesn't get bigger as more queries are performed and it is easier to access the number of rows from your last query because you don't need to know the $result id to know which element of the array to access. --- mysql2.php Fri Sep 27 09:58:31 2002 +++ mysql.php Fri Sep 27 10:00:09 2002 @@ -227,7 +227,7 @@
             if (is_object($numrows)) {
                 return $numrows;
             }
-            $this->num_rows[$result] = $numrows;
+            $this->num_rows = $numrows;
             return $result;
         }
         return DB_OK;
-Jason

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