title: Simple HTML DOM causes memory exhaustion when included
body: <p>I have a template with a couple of includes and use <code>Simple HTML DOM</code> for various tasks.</p>
  
  <p>When I inlcude the library, on some pages I get the following error:</p>
  
  <blockquote>
    <p>Fatal error: Allowed memory size of 134217728 bytes exhausted (tried
    to allocate 28672 bytes) in C:\xampp\htdocs\aa\template.php on line
    142</p>
  </blockquote>
  
  <p>This is my php code in the template:</p>
  
  <pre><code>&lt;?php
  $currentFile = $_SERVER["PHP_SELF"];
  $parts = Explode('/', $currentFile); 
  $page = $parts[count($parts) - 1];
  $parent = basename(dirname($_SERVER['PHP_SELF']));
  $both = $parent.'/'.$page;
  $content = $filename.".html";
  $sidebar = $filename. "-sidebar.html";
  
  ?&gt;
  &lt;?php include('dom.php'); ?&gt;
  &lt;?php 
  
  if (!isset($title)) {
  $html = file_get_html($_SERVER['DOCUMENT_ROOT'].'/aa/content/'.$content);
  
  $element = $html-&gt;find('h1'); 
  if ($element) {
  $titletag = $element[0]-&gt;plaintext . ' | about-berlin.com';
  }
  
      }
  else {
  $titletag = $title; 
  }
  $html-&gt;__destruct();
  ?&gt;
  &lt;!DOCTYPE html&gt;
  </code></pre>
  
  <p>The odd thing is I get the same memory error even when I only include the library like this, without any code using it:</p>
  
  <pre><code>&lt;?php include('dom.php'); ?&gt;
  </code></pre>
  
  <p>If I dont include it everything runs without an error. </p>
  
  <p>How is it possible to get this error without even using the <code>file_get_html()</code> which seem to be responsible for most problems? What could I try to fix this problem without changing <code>php.ini</code>?</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>Some clarification. My templating works like this:</p>
  
  <p>somepage.php is requested.
  Inside is the following code:</p>
  
  <pre><code>&lt;?php 
  $path_parts = pathinfo(__FILE__);
  $filename = $path_parts['filename'];
  
  include ($_SERVER['DOCUMENT_ROOT'].'/aa/template.php');
  ?&gt;
  </code></pre>
  
  <p>In the template the content file of the same name (somepage.php) is included from a folder called content.</p>