public function getIterator() {// This is the culprit. Combined with the passing of $this, // neither this object nor the iterator will be destroyed until // php has finished execution and cleans up.return $this->iterator ? $this->iterator : $this->iterator = new MyIterator($this); }