Page 1 of 1
Including Function Script File - Memory Issue ?
Posted: Fri Jun 11, 2004 7:27 am
by anjanesh
I have some 1000 functions that are required in many scripts. Many functions are required by all scripts but not all functions are required in a script.
So I put these functions in a functions.php script and this file is included in the scripts.
If a script requires just one function from the functions.php will the other 999 load as well ? Will this be a memory issue ? If so then how do I avoid this ?
Thanks
Anjanesh
Posted: Fri Jun 11, 2004 7:35 am
by dull1554
if im not mistaken they all will be loaded at ruintime, but its not outputted to the user so i dont think it will cause any issuses, but thats just my opinion
another soultion would be to break up your functions into individual files(functionName.txt) then just include the required ones, or build classes that contain clusters, like 50 functions but how you have it now i dont think will cause a problem.
Posted: Fri Jun 11, 2004 8:13 am
by Grim...
1000 functions!
How do you remember what they all do?
Posted: Fri Jun 11, 2004 9:19 am
by Saethyr
anjanesh,
I found it easier to create multiple files for example:
fncStrings.php
fncEmail.php
fncDb.php
etc..
This breaks my library into about 15 or 20 files and I only include what I need at that point, seems to me including a file with 1000 functions, which I am guessing is about 5k-15k lines of code would slow your applications to a crawl. Now I could be wrong on this, but it is just my opinion to only include what you need. Waste not want not

Posted: Fri Jun 11, 2004 11:16 am
by feyd
Agreed Saethyr, most of my functions are broken into seperate groups. Easy to swallow chunks, so to speak. Then I have a few include files that pool several commonly used ones together, so all I have to do is load the pool, instead of loading 10 different includes..
Posted: Fri Jun 11, 2004 12:21 pm
by anjanesh
Thats true indeed. I just wanted to know about the memory issue when it comes to running it on the server. If all the 1000 functions are included with the calling script or only the ones that are called.
Posted: Fri Jun 11, 2004 12:34 pm
by feyd
from what I've seen, the function will exist, but not parsed until it is referenced/called within the run code.