Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-31-2013, 01:01 AM   PM User | #1
prizegrand
New Coder

 
Join Date: Dec 2011
Posts: 32
Thanks: 2
Thanked 0 Times in 0 Posts
prizegrand is an unknown quantity at this point
php memory question!

Hi everyone,

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.
prizegrand is offline   Reply With Quote
Old 01-31-2013, 02:50 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:33 AM.


Advertisement
Log in to turn off these ads.