Bug #60983 [NEW]: Memory is not properly freed

From: Date: Mon, 06 Feb 2012 00:43:46 +0000
Subject: Bug #60983 [NEW]: Memory is not properly freed
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-167195@lists.php.net to get a copy of this message
From:             
Operating system: all
PHP version:      5.4.0RC7
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:Memory is not properly freed

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 bug report at https://bugs.php.net/bug.php?id=60983&edit=1
-- 
Try a snapshot (PHP 5.4):            https://bugs.php.net/fix.php?id=60983&r=trysnapshot54
Try a snapshot (PHP 5.3):            https://bugs.php.net/fix.php?id=60983&r=trysnapshot53
Try a snapshot (trunk):              https://bugs.php.net/fix.php?id=60983&r=trysnapshottrunk
Fixed in SVN:                        https://bugs.php.net/fix.php?id=60983&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60983&r=needdocs
Fixed in release:                    https://bugs.php.net/fix.php?id=60983&r=alreadyfixed
Need backtrace:                      https://bugs.php.net/fix.php?id=60983&r=needtrace
Need Reproduce Script:               https://bugs.php.net/fix.php?id=60983&r=needscript
Try newer version:                   https://bugs.php.net/fix.php?id=60983&r=oldversion
Not developer issue:                 https://bugs.php.net/fix.php?id=60983&r=support
Expected behavior:                   https://bugs.php.net/fix.php?id=60983&r=notwrong
Not enough info:                     https://bugs.php.net/fix.php?id=60983&r=notenoughinfo
Submitted twice:                     https://bugs.php.net/fix.php?id=60983&r=submittedtwice
register_globals:                    https://bugs.php.net/fix.php?id=60983&r=globals
PHP 4 support discontinued:          https://bugs.php.net/fix.php?id=60983&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=60983&r=dst
IIS Stability:                       https://bugs.php.net/fix.php?id=60983&r=isapi
Install GNU Sed:                     https://bugs.php.net/fix.php?id=60983&r=gnused
Floating point limitations:          https://bugs.php.net/fix.php?id=60983&r=float
No Zend Extensions:                  https://bugs.php.net/fix.php?id=60983&r=nozend
MySQL Configuration Error:           https://bugs.php.net/fix.php?id=60983&r=mysqlcfg



Thread (3 messages)

« previous php.bugs (#167195) next »