Re: Negative memory_get_usage() Values

From: Date: Sun, 26 Nov 2006 21:27:58 +0000
Subject: Re: Negative memory_get_usage() Values
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-245156@lists.php.net to get a copy of this message
Okay, I modified the script as follows to allow for collecting data and graphed it. The graph is at http://dented-planet.net/graph.png (sorry, I'm not versed in created perfect charts). <?php $x = ''; for ($i = 1; $i <= 20000; $i++) {
    $x = utf8_encode('this is a test');
    if ($i % 100 === 0) {
        echo $i . ' ' . memory_get_usage() . ' ' . memory_get_usage(true) . "\n";
    }
} ?> Chris chris@dented-planet.net On Nov 26, 2006, at 12:34 PM, Richard Lynch wrote:
What version of PHP and what OS? I *think* that there is some jiggery-pokery going on in memory_get_usage() in PHP 5 and managed memory where it would make perfect sense to get negative numbers occasionally... You may also want to log the memory_get_usage inside the loop, and then graph the memory usage as it goes up/down to get a better idea of what's going on. On Sun, November 26, 2006 8:35 am, Chris wrote:
Hey gang, I'm getting a negative return value from memory_get_usage() using the following script. My I've got --enable-memory-limit enabled and my memory_limit is set to 100MB (which should more than enough memory). I suspect that there is a bug in utf8_encode() but I'd like others to test it (on different platforms) before I submit it as a bug. <?php for ($i=0; $i < 20000; $i++) {
     echo utf8_encode('This is a test');
} echo memory_get_usage(); ?> Chris chris@dented-planet.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
--Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?


« previous php.general (#245156) next »