Bug #67459 [NEW]: DOMDocument memory hanldling
| From: | goetas at gmail dot com | Date: | Tue, 17 Jun 2014 06:45:10 +0000 |
| Subject: | Bug #67459 [NEW]: DOMDocument memory hanldling | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-186219@lists.php.net to get a copy of this message | ||
From: goetas at gmail dot com
Operating system: ubuntu
PHP version: 5.5.13
Package: DOM XML related
Bug Type: Bug
Bug description:DOMDocument memory hanldling
Description:
------------
Strange object allocation issue, maybe related to PHP/LIBXML memory
handling.
I've supposed that PHP releases the object associated to $root when I
unset it (even if this object can be reached through
$dom->documentElement).
Later, when I create the $ele element, it takes the same memory position
of $root.
LIBXML version 2.7.8
Test script:
---------------
$dom = new \DOMDocument('1.0', 'UTF-8');
$root = $dom->createElement('root');
$dom->appendChild($root);
$h1 = spl_object_hash($root);
$h2 = spl_object_hash($dom->documentElement);
var_dump($root === $dom->documentElement); // true, OK
var_dump($h1 === $h2); // true, OK
unset($root);
$ele = $dom->createElement('ele');
$h3 = spl_object_hash($ele);
$h4 = spl_object_hash($dom->documentElement);
var_dump($h1 === $h3); // expected to be false, but actually true
var_dump($h1 === $h4); // expected to be true, but actually false
Expected result:
----------------
bool(true)
bool(true)
bool(false)
bool(true)
Actual result:
--------------
bool(true)
bool(true)
bool(true)
bool(false)
--
Edit bug report at https://bugs.php.net/bug.php?id=67459&edit=1
--