Re: Re: DB getAll method has memory leaks

From: Date: Sat, 28 Sep 2002 07:02:50 +0000
Subject: Re: Re: DB getAll method has memory leaks
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-9627@lists.php.net to get a copy of this message
Martin Jansen wrote:
On Fri Sep 27, 2002 at 10:0447AM -0700, Jason Rust wrote:
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.
I guess Stig had a good reason for making this an array and it isn't a good idea perhaps to make it a scalar now.
Hmm...good point. What about just doing unset($this->num_rows) right before assigning the value. -Jason

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