Index: CHANGELOG.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/grammar_parser/CHANGELOG.txt,v
retrieving revision 1.60
diff -u -p -r1.60 CHANGELOG.txt
--- CHANGELOG.txt	23 Apr 2010 05:46:03 -0000	1.60
+++ CHANGELOG.txt	7 Jun 2010 22:00:50 -0000
@@ -2,6 +2,10 @@
 
 pgp (grammar parser) 7.x-1.x, 2009-xx-xx (development version)
 ----------------------------------------
+- Changes (2010-06-07):
+  * list.inc, reader.inc
+  * - #779528: improve memory releasing code to avoid unbounded memory usage
+
 - Changes (2010-04-22):
   * list.inc
   * - correct parsing of statements with '@' (in particular before the new operator)
Index: engine/grammar_parser.list.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/grammar_parser/engine/grammar_parser.list.inc,v
retrieving revision 1.36
diff -u -p -r1.36 grammar_parser.list.inc
--- engine/grammar_parser.list.inc	24 Apr 2010 23:42:15 -0000	1.36
+++ engine/grammar_parser.list.inc	7 Jun 2010 22:00:50 -0000
@@ -59,7 +59,7 @@ class PGPNode {
    */
   public $line;
 
-  function __construct(&$data, &$container) {
+  public function __construct(/*&*/$data, /*&*/$container) {
     $this->data = $data;
     $this->container = $container;
   }
@@ -234,7 +234,7 @@ class PGPList {
    */
   protected $debug = FALSE; // TRUE; //
 
-  function __construct() {
+  public function __construct() {
     $data = NULL;
     $this->first = new PGPNode($data, $this);
     $this->last = new PGPNode($data, $this);
@@ -554,6 +554,8 @@ class PGPList {
     $current->previous->next = &$current->next;
     $current->next->previous = &$current->previous;
 
+//     unset($current->next); // JB No effect // JB 2010-06-03
+//     unset($current->previous);
     unset($current);
 
     $this->count--;
@@ -1532,11 +1534,23 @@ class PGPList {
 //        $this->debugPrint("data is string '$data'");
       }
       unset($data);
+      unset($current->container);
 
       $next = &$current->next;
-      $this->delete($current);
+      // JB 2010-06-03
+//       $this->delete($current);
+      unset($current->data->parent);
+      unset($current->next);
+      unset($current->previous);
+      unset($current);
       $current = &$next;
     }
+    // JB 2010-06-03 -- these are helpful based on refcount.php
+    unset($this->parent);
+//    unset($this->first->next); -- no effect based on refcount.php
+//    unset($this->last->previous);
+    unset($this->first);
+    unset($this->last);
   }
 
   /**
@@ -1567,6 +1581,9 @@ class PGPList {
         $data = &$item->data;
         $data->clear_r();
         unset($data);
+        // JB 2010-06-03
+        unset($item->next);
+        unset($item->previous);
       }
       else {
 //        $this->debugPrint("item is string '$item'");
Index: engine/grammar_parser.reader.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/grammar_parser/engine/grammar_parser.reader.inc,v
retrieving revision 1.43
diff -u -p -r1.43 grammar_parser.reader.inc
--- engine/grammar_parser.reader.inc	23 Apr 2010 05:46:03 -0000	1.43
+++ engine/grammar_parser.reader.inc	7 Jun 2010 22:00:50 -0000
@@ -1289,7 +1289,7 @@ class PGPReader extends PGPParser {
             }
             // This is a function call.
             $node->setData('operand', $this->buildFunctionCall());
-            $node->data->parentExpression = &$expression; // THIS IS THE SPOT!!!
+//            $node->data->parentExpression = &$expression; // THIS IS THE SPOT!!! // JB 2010-05-03
             $this->functionCalls[] = &$node->data;
             $this->debugPrint("LEAVING case T_STRING $expressions");
           }
