|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-01-28 23:24 UTC] 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 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Mon Mar 30 14:00:01 2026 UTC |
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.