diff -r 5b8604e8a689 token.module
--- a/token.module	Wed Dec 02 13:53:25 2009 -0800
+++ b/token.module	Wed Dec 02 15:20:22 2009 -0800
@@ -311,6 +311,20 @@
 
   $running = FALSE;
 
+  // To avoid a memory leak in PHP, we will destroy every top-level item which
+  // may be, or which may contain further down in its structure, a recursion to
+  // $object itself. Simply doing unset($object), $object = NULL, or $object =
+  // new stdClass() will not properly signal to PHP's garbage collector to
+  // release the object's memory. See:
+  // http://drupal.org/node/648266
+  // http://paul-m-jones.com/?p=262
+  // PHP 4 can't iterate over objects; thus, the array typecasting trickery. 
+  foreach (array_keys((array)$object) as $key) {
+    if (is_array($object->{$key}) || is_object($object->{$key})) {
+      unset($object->{$key});
+    }
+  }
+  
   return $result;
 }
 
