PHP4 vs PHP5 Beta 3 : memory usage

php.internals

Armel FAUVEAU

22 years ago
Hi all, I wanted to compare the memory usage of PHP4 and PHP5 (Beta 3) on a same script. And i observed a strange problem. So, here is a small test (if you want to reproduce it). First, i write a small and short php script. It just make a simple memory_get_usage() (with a number_format for the presentation :p) : <?php print number_format(memory_get_usage(), 0, ',', ' ').' bytes'; ?> Second, i write a small shell script to call 100 times my php script by HTTP. I used lynx. And i stored the result in a logfile. Here is the code : #!/bin/sh for (( i = 1; i <= 100; i++ )); do lynx -dump http://localhost/armel/mem.php >> php.log done And here is the result... ---------------------------------------------------- With PHP4.3.4 (axps module) : armel@omble:~$ cat php.log 27 232 bytes 27 232 bytes ... ... 27 232 bytes 27 232 bytes ---------------------------------------------------- With PHP5 Beta3 (apxs module too) : armel@ombre:~$ cat php.log 211 952 bytes 153 784 bytes 108 184 bytes 157 680 bytes 94 376 bytes 107 392 bytes 446 888 bytes 558 712 bytes ... ... 107 392 bytes 446 888 bytes 557 656 bytes 211 952 bytes 153 784 bytes 108 184 bytes 157 680 bytes ---------------------------------------------------- The result under PHP4 is logical. But under PHP5 Beta 3, i think it's very very strange. What do you think about this ? Any idea ? Maybe my script can even be a good system of random pulling :)) Regards (and happy new year), Armel.

Jani Taskinen

22 years ago
I tried your script and couldn't reproduce such big numbers. Plus the memory usage leveled to 54152 bytes after some requests to each apache child. This was with using the latest CVS checkout of PHP 5. --Jani On Thu, 8 Jan 2004, Armel FAUVEAU wrote:

Armel FAUVEAU

22 years ago
Hi Jani, Thank's for your response.
> I tried your script and couldn't reproduce such big numbers. > Plus the memory usage leveled to 54152 bytes after some requests > to each apache child. This was with using the latest CVS checkout > of PHP 5.
Ok, i have make a test with the lastest CVS (Built On: Jan 08, 2004 18:30 GMT). And i obtain more logical and stable results (53 464 bytes). Note that, there are sometimes some changes. For exemple, here is a piece of the log sequence that i obtain : ... 53 464 bytes 53 464 bytes 50 440 bytes 51 024 bytes 53 464 bytes ... I don't really understand why that can evolve like that. With PHP4, results are always the same (and that seems normal :p). Regards, Armel.

Jani Taskinen

22 years ago
On Thu, 8 Jan 2004, Armel FAUVEAU wrote:
>Hi Jani, > >Thank's for your response. > >> I tried your script and couldn't reproduce such big numbers. >> Plus the memory usage leveled to 54152 bytes after some requests >> to each apache child. This was with using the latest CVS checkout >> of PHP 5. > >Ok, i have make a test with the lastest CVS (Built On: Jan 08, 2004 18:30 >GMT). And i obtain more logical and stable results (53 464 bytes). Note >that, there are sometimes some changes. For exemple, here is a piece of the >log sequence that i obtain : > >... >53 464 bytes >53 464 bytes >50 440 bytes >51 024 bytes >53 464 bytes >... > >I don't really understand why that can evolve like that. With PHP4, results >are always the same (and that seems normal :p).
Your apache is configured to kill childs after certain amount of requests so of course it makes this look like 'random'. There's nothing wrong here. --Jani

Armel FAUVEAU

22 years ago
> >I don't really understand why that can evolve like that. With PHP4,
results
> >are always the same (and that seems normal :p). > > Your apache is configured to kill childs after certain amount > of requests so of course it makes this look like 'random'. > There's nothing wrong here.
Yes, that could be a reason, but i'm not sure here. My MaxRequestsPerChild is setting to 0 (so unlimited request by child). Regards, Armel.