title: Why DOMDocument uses more memory then limit declared for PHP?
body: <p>I tried to check memory consumption for large XML files (over 1GB) by loading them into DOMDocument (Win/CLI PHP 8.0.3).</p>
  <p>I've noticed that memory used by process increases rapidly while loading file the file:</p>
  <pre><code>$dom = new DOMDocument();
  $dom-&gt;load($path);
  </code></pre>
  <p>Process used ca. 3GB of memory for a 1GB XML file. Memory limit for PHP was set to 128M. Moreover PHP did not reported almost any memory usage (<code>memory_get_usage</code>: 152 bytes for declared and 0 bytes for real). After performig XPath query memory showed by PHP rised by 32MB.</p>
  <p>I observed similar behaviour with <code>SimpleXMLElement</code> and even on Apache/PHP.</p>
  <p>It looks like DOMDocument and SimpleXMLElement uses some external memory included to memory used by process but not by PHP. When I tried with 4GB XML I touched the limit of my phisical memory (16GB) but process did not crashed.</p>
  <p>Does anybody know why it is going like that and what memory is used during loading XML? (or maybe you know how to control it...)</p>