Bug #53415 [Opn->Bgs]: memory_get_usage is inaccurate
Edit report at http://bugs.php.net/bug.php?id=53415&edit=1
ID: 53415
Updated by: scottmac@php.net
Reported by: thepixeldeveloper at googlemail dot com
Summary: memory_get_usage is inaccurate
-Status: Open
+Status: Bogus
Type: Bug
Package: Scripting Engine problem
Operating System: Linux durango 2.6.36-020636rc8-g
PHP Version: 5.3.3
Block user comment: N
Private report: N
New Comment:
$something is destroyed when the scope is lost and the memory is free'd
back to
PHP to use again. Hence the low value outside.
Maybe you're looking for memory_get_peak_usage()
Previous Comments:
------------------------------------------------------------------------
[2010-11-26 14:36:39] thepixeldeveloper at googlemail dot com
Description:
------------
memory_get_usage does not work correctly with reflection calls such as
invoke.
Test script:
---------------
<?php
class HelloWorld
{
public function sayHelloTo($name)
{
$s = memory_get_usage();
$something = str_repeat($name, pow(1024, 2));
echo 'Inside: ';
echo memory_get_usage() - $s.PHP_EOL;
}
}
$reflectionMethod = new ReflectionMethod('HelloWorld', 'sayHelloTo');
$s = memory_get_usage();
$reflectionMethod->invoke(new HelloWorld(), 'a');
echo 'Outside: ';
echo memory_get_usage() - $s;
Expected result:
----------------
Inside: 1048760
Outside: 1048760
Actual result:
--------------
Inside: 1048760
Outside: 92
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53415&edit=1
Thread (2 messages)