/**
  * clean up memory due to php5 circular references memory leak...
  */
 public function clear()
 {
     foreach ($this->nodes as $n) {
         $n->clear();
         $n = null;
     }
     // This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear.
     if (isset($this->children)) {
         /** @noinspection PhpWrongForeachArgumentTypeInspection */
         foreach ($this->children as $n) {
             if (is_object($n)) {
                 /** @noinspection PhpUndefinedMethodInspection */
                 $n->clear();
             }
             $n = null;
         }
     }
     if (isset($this->parent)) {
         $this->parent->clear();
         unset($this->parent);
     }
     if (isset($this->root)) {
         $this->root->clear();
         unset($this->root);
     }
     unset($this->doc, $this->docArray, $this->noise, $this->parent, $this->root);
 }
示例#2
0
 public static function str_get_html($str, $lowercase = true, $forceTagsClosed = true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT, $defaultSpanText = DEFAULT_SPAN_TEXT)
 {
     $dom = new SimpleHtmlDom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
     if (empty($str) || strlen($str) > MAX_FILE_SIZE) {
         $dom->clear();
         return false;
     }
     $dom->load($str, $lowercase, $stripRN);
     return $dom;
 }