Description
Description
My application uses DOMElement
to work on large XML files and manipulates them extensively. I observed a significant increase in peak memory usage between PHP 8.0 and PHP 8.1 while running the same code base, despite performing the same number of operations (200k DOMElement::setAttribute
calls).
Peak memory usage increased from 30MB in PHP 8.0 to 100MB in PHP 8.1, despite similar operations being performed.
The issue persists across multiple PHP minor versions from PHP 7.4.33 to PHP 8.3.6.
I attempted to reproduce the issue in a minimal code snippet and observed that stored DOMElement
objects consume increasingly more memory with each PHP version.
Resulted in this output:
With 25 000 DOMElement
PHP Version Range | Memory Usage |
---|---|
8.3.0 - 8.3.6 | 16 MB |
8.1.0 - 8.1.28, 8.2.0 - 8.2.18 | 14 MB |
7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30 | 4 MB |
With 40 000 DOMElement
PHP Version Range | Memory Usage |
---|---|
8.3.0 - 8.3.6 | 24 MB |
8.2.0 - 8.2.18, 8.1.0 - 8.1.28 | 22 MB |
7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30 | 8 MB |
But I expected memory usage to remain consistent across PHP versions, especially when performing the same operations.
PHP Version
PHP 8.1.0-8.3.6
Operating System
No response