Page 1 of 1
.cfg file question
Posted: Wed Dec 19, 2007 2:17 pm
by coltain
When I read a cfg file (using ReadConfigFile(filename)) do I have to unload this .cfg file??? Or is it unloaded automaticly when script ends (or exits by return)???
Posted: Thu Dec 20, 2007 9:08 am
by tekproxy
You don't have to but it's good practice to.
If you do not unload it it should be unloaded for you when it's no longer referenced.
Posted: Thu Dec 20, 2007 4:58 pm
by Austin
When you load a config file with ReadConfigFile() it parses it and stores it internally for faster usage later on when you use it in other scripts (it has to be read in the same way though)
If you unload it in a script, it removes the data from the cache and has to be reparsed again.
Posted: Sat Dec 22, 2007 3:28 pm
by coltain
So what is better???
for eg.
I have readconfigfile(something) in my AI script (for setup). This script is used by about 10000 mobiles. Is it better not to unload this config after setup or it is better to unload it?
Posted: Sat Dec 22, 2007 3:41 pm
by Austin
If you only need a config file once then unload it.
If you write to a config file you must unload it to have it updated in memory.
Most the time you don't want to unload a config file because it will have to be removed/reread.
The config file on the first use is parsed and stored in memory.
Every time after that, it is retrieved from memory for speed.
If you call UnloadConfigFile() then the next time ReadConfigFile() is used, the file must be read from disk and parsed back into memory.