Edit report at https://bugs.php.net/bug.php?id=60983&edit=1
ID: 60983 Updated by: larue...@php.net Reported by: developerguy2008 at yahoo dot com Summary: Memory is not properly freed -Status: Open +Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: all PHP Version: 5.4.0RC7 Block user comment: N Private report: N New Comment: the reason for there is mem diff is that, the EG(objects_store) could only be grow but could not be shrunk. if you tweak your test into: $mem1 = memory_get_usage(true); echo "MEM1: " . $mem1 . "\n"; class A { public $class; } $c1 = $c2 = null; for ($i = 0; $i < 20000; $i++) { $c1 = new A(); $c2 = new A(); $c1->class = array($c1, $c2); $c2->class = array($c1, $c2); gc_collect_cycles(); } unset($c1); unset($c2); $mem2 = memory_get_usage(true); echo "MEM2: " . $mem2 . "\n"; echo "DIFF: " . ($mem2 - $mem1) . "\n"; you may understand my point Previous Comments: ------------------------------------------------------------------------ [2012-02-06 00:43:46] developerguy2008 at yahoo dot com Description: ------------ Memory is not being freed properly. In a short loop several megabytes are lost that should not be lost. Attached is a test script to demonstrate what I mean. Test script: --------------- $mem1 = memory_get_usage(true); echo "MEM1: " . $mem1 . "\n"; class A { public $class; } $c1 = $c2 = null; for ($i = 0; $i < 20000; $i++) { $c1 = new A(); $c2 = new A(); $c1->class = array($c1, $c2); $c2->class = array($c1, $c2); } unset($c1); unset($c2); gc_collect_cycles(); $mem2 = memory_get_usage(true); echo "MEM2: " . $mem2 . "\n"; echo "DIFF: " . ($mem2 - $mem1) . "\n"; Expected result: ---------------- I expect the memory difference to be 0. In this case it is several megabytes. Actual result: -------------- MEM1: 4980736 MEM2: 7340032 DIFF: 2359296 The DIFF should be 0. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60983&edit=1