I have a PHP class in a large 200KB file. When I do:
include_once('myClass.php');
$theClass = new myClass();
what exactly is loaded into the server’s RAM? Is it the whole 200KB (fields + functions) or only the class fields? Are function definitions only loaded into RAM when they’re called? Should I split this big class into many sub-classes to boost server performance?
The reason my split would be more efficient is because the include would be located inside a function, which you would only call when you need the classes, sub-classes, or functions located inside that file.
Wow, this is very interesting to me. I have always wondered how much memory is being used when I create a class or include a file with PHP… and what should be the maxmium or how much I should stay away from (err… if that could be judged or something, probably depends on the content or site).
May I ask what you guys are getting when you use the function memory_get_usage(true) at the very end of your scripts (after the HTML)? (it also helps to divide by 1024 twice…) I am asking just because I am curious of what the average is… thanks