What potential pitfalls should be considered when using DOMDocument and DOMNode in PHP?

When using DOMDocument and DOMNode in PHP, it's important to be aware of potential pitfalls such as memory leaks and performance issues. To avoid these problems, make sure to properly free up memory by explicitly calling unset() on DOMDocument and DOMNode objects when they are no longer needed.

// Create a DOMDocument object
$doc = new DOMDocument();

// Load XML content into the DOMDocument
$doc->loadXML($xmlContent);

// Process the XML content

// Free up memory by unsetting the DOMDocument object
unset($doc);