Re: [PHP] Negative memory_get_usage() Values



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@xxxxxxxxxxxxxxxxx



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@xxxxxxxxxxxxxxxxx

--
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?


.



Relevant Pages

  • Re: [PHP] Negative memory_get_usage() Values
    ... What version of PHP and what OS? ... memory_get_usage() in PHP 5 and managed memory where it would make ... I suspect that there is a bug in utf8_encodebut I'd like others to ... echo utf8_encode; ...
    (php.general)
  • Re: Apache and Tux running together
    ... my job we've got a web based product provided by Apache running PHP ... This web application is hosted by multiple servers ... out on the number of httpd processes and falls behind to the ... so I'm thinking I'm memory bound. ...
    (comp.lang.php)
  • Re: Can I measure how much memory an object consumes?
    ... to calculate or measure how much memory these 100 request objects will ... which parts of the graph do you want to recurse?". ... the CLOS instance ... and its data vector separately, ...
    (comp.lang.lisp)
  • Re: imagecreatetruecolor sometimes causes forced-download of index.php for some JPEG images
    ... You have a severe problem in either the specific version of PHP you are ... You're unlikely to get any support from bugs.php.net either unless you upgrade ... with memory_limit set to 32M, and memory_get_usagesays that the memory ... Memory usage: 9490728 ...
    (comp.lang.php)
  • Re: How do I get Graph to be "within" Word?
    ... Go to the Memory pane and raise Word's Preferred memory to ... Add a little bit more RAM to the preferred RAM setting for Word in ... >> I did exactly as you said and NOW I CAN EDIT GRAPHS! ... >> graph, place it, work on other graphs, but then when I go back to edit ...
    (microsoft.public.mac.office.word)