ID:               36924
 User updated by:  arnout at argeweb dot nl
 Reported By:      arnout at argeweb dot nl
 Status:           Open
 Bug Type:         Scripting Engine problem
 Operating System: FreeBSD 5.4-RELEASE-p11
 PHP Version:      5.1.2
 New Comment:

"Using the following code leaks 32 bytes of memory."

Cleaning up the demo-script while submitting this bug gave a clearer
image. The demo says it all.
Using unset() didn't change anything anywhere by the way.


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

[2006-03-30 15:54:06] arnout at argeweb dot nl

Description:
------------
Using the following code leaks 32 bytes of memory.

$doe = 'yoyoyo';
echo "john $doe";



PHP 5.1.2 (cli) (built: Feb 22 2006 16:17:32)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
    with Zend Extension Manager v1.0.10, Copyright (c) 2003-2006, by
Zend Technologies
    with Zend Optimizer v3.0.0-Beta2, Copyright (c) 1998-2006, by Zend
Technologies


Reproduce code:
---------------
<?php

@ob_end_flush(); // to be sure


function fake1( $string ){
        echo "kaas ".$string;
}

function fake2( $string ){
        echo "kaas $string";
}

function fake3( $string ){
        $string = "kaas $string";
}

function fake4( $string ){
        echo "kaas $string asdf";
}


echo "<P><b>function fake1</b></p>";

for( $i = 0;$i < 10; $i++ ){
        echo "Memory at ".$i.": ".memory_get_usage()."<Br>\n";
        fake1( "string" );
        echo "Memory at ".$i.": ".memory_get_usage()."<Br>\n";
}

echo "<P><b>function fake2</b></p>";

for( $i = 0;$i < 10; $i++ ){
        echo "Memory at ".$i.": ".memory_get_usage()."<Br>\n";
        fake2( "string" );
        echo "Memory at ".$i.": ".memory_get_usage()."<Br>\n";
}

echo "<P><b>function fake3</b></p>";

for( $i = 0;$i < 10; $i++ ){
        echo "Memory at ".$i.": ".memory_get_usage()."<Br>\n";
        fake3( "string" );
        echo "Memory at ".$i.": ".memory_get_usage()."<Br>\n";
}

echo "<P><b>function fake4</b></p>";

for( $i = 0;$i < 10; $i++ ){
        echo "Memory at ".$i.": ".memory_get_usage()."<Br>\n";
        fake4( "string" );
        echo "Memory at ".$i.": ".memory_get_usage()."<Br>\n";
}


?>

Expected result:
----------------
Hardly any change in memory usage.

Actual result:
--------------
function fake1
Memory at 0: 42920
kaas stringMemory at 0: 42984
Memory at 1: 42984
kaas stringMemory at 1: 42984
Memory at 2: 42984
kaas stringMemory at 2: 42984
Memory at 3: 42984
kaas stringMemory at 3: 42984
...etcetera... +64 bytes, only once.

function fake2
Memory at 0: 42984
kaas stringMemory at 0: 43000
Memory at 1: 43000
kaas stringMemory at 1: 43016
Memory at 2: 43016
kaas stringMemory at 2: 43032
Memory at 3: 43032
kaas stringMemory at 3: 43048
...etcetera... +16 bytes

function fake3
Memory at 0: 43144
Memory at 0: 43160
Memory at 1: 43160
Memory at 1: 43176
Memory at 2: 43176
Memory at 2: 43192
Memory at 3: 43192
Memory at 3: 43208
...etcetera... +16 bytes

function fake4
Memory at 0: 43304
kaas string asdfMemory at 0: 43328
Memory at 1: 43328
kaas string asdfMemory at 1: 43352
Memory at 2: 43352
kaas string asdfMemory at 2: 43376
...etcetera... +24 bytes


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


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

Reply via email to