Hi all,
I am trying to get an estimate on how much memory my scripts are using.. I am growing more concerned as I keep adding functionality to my site.. so far I'm up to about 15 different classes (user class, customer class, personnel class, etc. etc).. so 15 different includes on each page.. man.. that's gotta be hard on apache I figure.
I'm apache, winxp, php5, on the dev. server.
I don't have the option to compile with memory_limit flags to get memory_get_Usage() so I got this code from php.net and it produces:
Array ( [0] => [1] => Image Name: httpd.exe [2] => PID: 1816 [3] => Session Name: Console [4] => Session#: 0 [5] => Mem Usage: 18,676 K )
But I'm thinking this is telling me that the entire apache process is using 18M? When I try to open a new browser window and go to the same page, trying to hit refresh on both at the same time (or close, whatever), the PID does not change.. so that's why I'm thinking it's just the entire apache process, unlike the native memory_get_usage() function.
I have tried to deduce the following:
running memory_get_usage() yields 14M at the very beginning of the script.
running memory_get_usage() yields 18M at the very end of the script.
including ~200 functions in a 145K include file spikes the memory usage 2MB alone.
the way i have my site, i have frontend pages: app_admin.php, customer_admin.php, etc. and then I include the functions.php into all of them -- however it seems like it may be better (memory-wise) to put functions that are specific to each frontend page in the frontend, and in the case I need to reuse the function, move it into functions.php which is included throughout.
*4M per "session" is required per client, so if I expect 250 simultaneous users, I need 1GB free worst case (all 250 sessions hit per second)
Interesting tidbits.. I tried the following code:
echo memory_get_usage() . ",b4<br>";
for ( $i = 0; $i < 10000; $i++ )
{
$test = new appointment();
$test2 = new customer();
$test3 = new company();
}
echo memory_get_usage() . ",aft<br>";
and it produces the following:
Array ( [0] => [1] => Image Name: httpd.exe [2] => PID: 1976 [3] => Session Name: Console [4] => Session#: 0 [5] => Mem Usage: 17,124 K )
Array ( [0] => [1] => Image Name: httpd.exe [2] => PID: 1976 [3] => Session Name: Console [4] => Session#: 0 [5] => Mem Usage: 17,128 K )
which is quite amazing.. after 30,000 instantiated objects only 4K of memory was additionally allocated. (considering on just the three includes of the three classes memory went from 16.6M to 17M -- about 400K memory allocated)
also, my linux is a bit rusty.. if I've installed via RPM/yum apache on my prd (fedora) server, how do I enable the memory flag since I never really "compiled" it?
THanks,