OOP and RAM usage

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?

No, splitting them won’t do much. If you’re concerned with the memory usage of your scripts, monitor them with

http://us3.php.net/memory_get_usage

You might want to split it up, and then only load sub-classes of it when you need them.

Two conflicting opinions above: :expressionless:

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.

But it doesn’t matter, really. When you cache a class it’s available throughout the pipe, not just for the current socket…

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