ID:               47233
 Updated by:       scott...@php.net
 Reported By:      piotr dot banasik at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Class/Object related
 Operating System: Linux/os-x
 PHP Version:      5.3CVS-2009-01-28 (snap)
 New Comment:

Won't work until script shutdown because of the way the code is
written, you overwrite $a which is fine. But the garbage collector isn't
called on *every* destructor as that would be slow.

for ($i = 0 ; $i < 1000000 ; $i++) {
    $a = new A();
    unset($a);
    gc_collect_cycles();
}


Works fine though.


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

[2009-01-28 23:24:27] piotr dot banasik at gmail dot com

Description:
------------
This appears to be the same issue as the now closed bug #33595

I originally experienced this with php 5.2, after googling around I
stumbled upon #33595. It looked like it fixed the issue, so I grabbed
first the alpha, and then the snapshot of 5.3, neither of them appear to
have the issue fixed.

I'm using the op's original test code and memory usage jumps from
329,956 bytes before, to 1,027,088 after the 1mil iterations. (In my
actual way more complex code this is causing ~20k per iteration memory
jumps so its very non trivial to me).

Reproduce code:
---------------
<?php
class A {
    function __construct () {
        $this->b = new B($this);
    }
}

class B {
    function __construct ($parent = NULL) {
        $this->parent = $parent;
    }
}

echo number_format(memory_get_usage()) . "\n";

for ($i = 0 ; $i < 1000000 ; $i++) {
    $a = new A();
}

echo number_format(memory_get_usage()) . "\n";

?>

Expected result:
----------------
the before and after memory usage should not go up by much

Actual result:
--------------
329,956
1,027,088


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


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

Reply via email to