From 7bedb0b21d9843a58cd37066127744b5a6840be4 Mon Sep 17 00:00:00 2001 From: romanb Date: Wed, 29 Aug 2007 18:40:58 +0000 Subject: [PATCH] Added Doctrine_Query::free() to make it possible to help PHPs current GC --- lib/Doctrine/Query.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/Doctrine/Query.php b/lib/Doctrine/Query.php index f366281e3..bfd6e89c0 100644 --- a/lib/Doctrine/Query.php +++ b/lib/Doctrine/Query.php @@ -1544,4 +1544,18 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable return $new; } + + /** + * Frees the resources used by the query object. It especially breaks a + * cyclic reference between the query object and it's parsers. This enables + * PHP's current GC to reclaim the memory. + * This method can therefore be used to reduce memory usage when creating a lot + * of query objects during a request. + */ + public function free() { + $this->reset(); + $this->_parsers = array(); + $this->_dqlParts = array(); + $this->_enumParams = array(); + } } \ No newline at end of file