79153549

Date: 2024-11-03 20:10:45
Score: 2
Natty:
Report link

You can resolve this memory issue by using the

XMLReader

PHP class instead of

DOMDocument

If you're using the Magento framework, you can use

Laminas\Config\Reader\Xml

instead of

Magento\Framework\Xml\Parser

class.

DOMDocument class will try to load all the XML content to memory at once but XMLReader class will NOT load the content to memory at once. It will read the nodes set by set incrementally.

You can find more info on this one in this article https://medium.com/devops-dev/way-to-read-large-xml-dataset-in-magento-2-using-laminas-config-reader-xml-2b59c936bbcc :)

Cheers!

Reasons:
  • Blacklisted phrase (1): Cheers
  • Blacklisted phrase (1): this article
  • Blacklisted phrase (0.5): medium.com
  • Whitelisted phrase (-1.5): you can use
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: Dasitha Abeysinghe