Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Global variables and Local Map variables.
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#7
RE: Global variables and Local Map variables.

I imagine (but can't confirm, this is all just a hypothesis) that the SetLocalVar string-value pairs are stored in some kind of mapping (probably hashtable) which is constructed as the variables are declared. When a save occurs all the pairs are just dumped to the save file and when a load occurs all are loaded back in. The bindings are probably not cleared until ClearSavedMaps() [testing needed] is called from a different map [they shouldn't be cleared before this as the game wont know what variables will be re-used again]. The consequences to this means implementing arrays or lists by string concatenation with a number will "leak", and as such a different approach should (and can - see my string list implementation) be taken.

SetGlobalVar vars will work in the same way but will always be loaded in any map after creation and probably aren't affected by ClearSavedMaps (Again, testing needed). GetLocalVar / GetGlobal var on a non-existant var will return 0 (or the empty string) but i am uncertain if this also creates an entry for the var, or if entry creation only occurs when writing to a var.

Of course, in scripts the leak potential is not a problem is 99% of cases - you would have to go through a huge number of variables to even make a dent in memory usage (think about the size of one skybox texture for instance - An integer is going to be 4 bytes here - that is quite a lot of integers!). I actually think save file size would become just as much an issue as memory usage. Also that kind of computation is something we aren't rarely going to have to deal with in amnesia, so i wouldn't really worry about it unless you are going to be computing on larger volumes of data than normal.
(This post was last modified: 04-29-2012, 02:39 AM by Apjjm.)
04-29-2012, 02:36 AM
Find


Messages In This Thread
RE: Global variables and Local Map variables. - by Apjjm - 04-29-2012, 02:36 AM



Users browsing this thread: 1 Guest(s)