Hello and welcome to our community! Is this your first visit?
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
    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. #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,668 Times in 2,637 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'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


Posting Permissions

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