Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    34
    Thanks
    2
    Thanked 0 Times in 0 Posts

    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.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 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'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •