Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: php memory question!
01-31-2013, 02:01 AM #1
- Join Date
- Dec 2011
- Thanked 0 Times in 0 Posts
php memory question!
Quick question here:
Do you think i can lower my overall RAM usage if i only include the classes and functions on the pages i need the class/functions on?
For example, if i need the class "api.php" only on useapi.php, would i save/conserve memory by including it only on that page instead of globally in my header? Please let me know of the answer.
01-31-2013, 03:50 PM #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,662 Times in 2,631 Posts
You sure would. The fewer symbols you need to use, the less memory it will use to run. This is why I've never recommended a single script to handle *every* custom function in use, rather split the scripts into logical groups of *what* the functions do. Classes are simply an extension on this same logic. Single script per class chained with namespace autoloading means I can limit the memory in use to just the required classes. Only downside is I sacrifice a bit of time since I don't explicitly issue an include/require and let the namespace resolution do its job instead. The time wasted is completely negligible, and IMO is well worth the flexibility by never issuing a require/include for my classes.PHP Code:
header('HTTP/1.1 420 Enhance Your Calm');