# PHP4 vs PHP5 Beta 3 : memory usage

- Thread: https://externals.io/message/6861
- Original archive: https://news-web.php.net/php.internals/6861
- Started by Armel FAUVEAU on 2004-01-08T17:45:21+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #6861 — Armel FAUVEAU — 2004-01-08T17:45:21+00:00

URL: https://externals.io/message/6861#6861

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.

---

## #6868 — Jani Taskinen — 2004-01-08T18:54:26+00:00

URL: https://externals.io/message/6861#6868 · In reply to: #6861

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
     



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

---

## #6884 — Armel FAUVEAU — 2004-01-08T20:00:07+00:00

URL: https://externals.io/message/6861#6884 · In reply to: #6868

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.

---

## #6887 — Jani Taskinen — 2004-01-08T20:02:58+00:00

URL: https://externals.io/message/6861#6887 · In reply to: #6884

>Hi Jani,
>
>Thank's for your response.
>
> > […]
>
>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

---

## #6895 — Armel FAUVEAU — 2004-01-08T20:38:30+00:00

URL: https://externals.io/message/6861#6895 · In reply to: #6887

> > […]
results
> > […]
>
>     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.
