ID:               44810
 Updated by:       [EMAIL PROTECTED]
 Reported By:      luka8088 at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         *XML functions
 Operating System: Windows
 PHP Version:      5.2.5
 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

You have a circular reference here.

$this->parser refers to itself, so when you unset($x) it only frees the
instance of $xml, but the object will still exist because it has
references to the parser. Therefore __destruct is never called to free
the parser.



Previous Comments:
------------------------------------------------------------------------

[2008-04-23 17:50:42] luka8088 at gmail dot com

Description:
------------
xml_set_object causes memory leak....

in example, an infinite loop i written which should not constantly
increase memory...

When xml_set_object($this->parser, &$this); is removed, memory leak
stops...

Reproduce code:
---------------
class xml
        {
        function __construct()
                {
                $this->parser = xml_parser_create();
                xml_set_object($this->parser, &$this);
                }
        
        function __destruct()
                {
                xml_parser_free($this->parser);
                }
        }

while (true)
        {
        usleep(1000);
        $x = new xml();
        unset($x);
        }

Expected result:
----------------
Nothing should happen ....

Actual result:
--------------
when below code is run.. memory usage increases 5 MB/s for abount 15
seconds and then:

PHP Fatal error:  Allowed memory size of 16777216 bytes exhausted
(tried to allocate 16 bytes) in D:\source\php\include\xml.php on line
18
Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to
allocate
16 bytes) in D:\source\php\include\xml.php on line 18


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44810&edit=1

Reply via email to