Hi,
I'm using PHP 4.x and I'm trying to understand a bit about memory usage...
Firstly, when I say 'include files' below, I mean all forms, include,
require and the _once versions.
That said, when a script runs and it's made of several include files,
what happens?
Are the include files only compiled when execution hits them, or are all
include files compiled when the script is first compiled, which would
mean a cascade through all statically linked include files. By
statically linked files I mean ones like "include ('bob.php')" - i.e the
filename isn't in a variable.
Secondly, are include files that are referenced, but not used, loaded
into memory? I.e Are statically included files automatically loaded into
memory at the start of a request? (Of course those where the name is
variable can only be loaded once the name has been determined.) And when
are they loaded into memory? When the instruction pointer hits the
include? Or when the script is initially loaded?
Are included files ever unloaded? For instance if I had 3 include files
and no loops, once execution had passed from the first include file to
the second, the engine might be able to unload the first file. Or at
least the code, if not the data.
Thirdly, I understand that when a request arrives, the script it
requests is compiled before execution. Now suppose a second request
arrives for the same script, from a different requester, am I right in
assuming that the uncompiled form is loaded? I.e the script is tokenized
for each request, and the compiled version is not loaded unless you have
engine level caching installed - e.g. MMCache or Zend Optimiser.
Fourthly, am I right in understanding that scripts do NOT share memory,
even for the portions that are simply instructions? That is, when the
second request arrives, the script is loaded again in full. (As opposed
to each request sharing the executed/compiled code, but holding data
separately.)
Fifthly, if a script takes 4MB, given point 4, does the webserver demand
8MB if it is simultaneously servicing 2 requests?
Lastly, are there differences in these behaviors for PHP4 and PHP5?
Many thanks,
Jeff
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php