Oct 222007
 

Here is the patch I just comitted which reduces the amount of RAM consumed.

[dan@ngaio:/usr/websites/freshports.org/classes] $ cvs di -ub display_commit.php
Index: display_commit.php
===================================================================
RCS file: /home/repositories/freshports-1/classes/display_commit.php,v
retrieving revision 1.8
diff -u -b -r1.8 display_commit.php
--- display_commit.php  10 Jul 2007 11:39:07 -0000      1.8
+++ display_commit.php  22 Oct 2007 17:22:23 -0000
@@ -87,19 +87,16 @@

                $i=0;
                $GlobalHideLastChange = "N";
-               for ($i = 0; $i < $NumRows; $i++) {
-                       $myrow = pg_fetch_array($this->result, $i);
-                       $mycommit = new CommitRecord();
-                       $mycommit->PopulateValues($myrow);
-                       $commits[$i] = $mycommit;
-               }

                $LastDate = '';

                $this->HTML = '';
                unset($ThisCommitLogID);
                for ($i = 0; $i < $NumRows; $i++) {
-                       $mycommit = $commits[$i];
+                       $myrow = pg_fetch_array($this->result, $i);
+                       unset($mycommit);
+                       $mycommit = new CommitRecord();
+                       $mycommit->PopulateValues($myrow);
                        $ThisCommitLogID = $mycommit->commit_log_id;

                        if ($LastDate <> $mycommit->commit_date) {
@@ -118,9 +115,12 @@
                        # count the number of ports in this commit
                        $NumberOfPortsInThisCommit = 0;
                        $MaxNumberPortsToShow      = 10;
-                       while ($j < $NumRows && $commits[$j]->commit_log_id == $ThisCommitLogID) {
+                       while ($j < $NumRows && $mycommit->commit_log_id == $ThisCommitLogID) {
                                $NumberOfPortsInThisCommit++;
-                               $mycommit = $commits[$j];
+                               $myrow = pg_fetch_array($this->result, $j);
+                               unset($mycommit);
+                               $mycommit = new CommitRecord();
+                               $mycommit->PopulateValues($myrow);

                                if ($NumberOfPortsInThisCommit == 1) {
                                        GLOBAL $freshports_mail_archive;
@@ -283,6 +283,8 @@
                        $this->HTML .= "\n</BLOCKQUOTE>\n</TD></TR>\n\n\n";
                }

+               unset($mycommit);
+
                return $this->HTML;
        }
 }
[dan@ngaio:/usr/websites/freshports.org/classes] $

It’s rather simple. Instead of storing each result tuple in an array, I fetch them as required. Seems to work. :)

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive