[php-src] Issue #13988: Storing DOMElement consume 4 times more memory in PHP 8.1 than in PHP 8.0
| From: | steffunky | Date: | Wed, 17 Apr 2024 14:13:10 +0000 |
| Subject: | [php-src] Issue #13988: Storing DOMElement consume 4 times more memory in PHP 8.1 than in PHP 8.0 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246775@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/13988
Author: steffunky
### 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.
https://3v4l.org/Aoi63
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_