• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Does having more variables lag the game?

Status
Not open for further replies.
A variable takes space in the ram.
If you have tons of variables that are all arrays of the maximum size it can start taking significant amounts of ram but if you are using only a dozen of arrays of the maximum size it is not going to give any problems.(as far as I know)
You can probably use tons and tons of variables that are not arrays.
 
Last edited:
A variable takes space in the ram.
If you have tons of variables that are all arrays of the maximum size it can start taking significant amounts of ram but if you are using only a dozen of arrays of the maximum size it is not going to give any problems.(as far as I know)
You can probably use tons and tons of variables that are not arrays.
RAM usage does not degrade performance as long as your system is not memory bound. With Warcraft III using up to 4GB of memory and modern computers having anywhere from 8GB to 16GB that is not a problem. The game will crash long before memory usage starts to degrade performance due to page thrashing.

I have heard from the grape vine that you want to have as few variables as possible, and that simply having a lot of variables will slow down the game. Does this happen by any noticeable amount? Does it have any validity to it?
Due to the way the hashtables work that are used for runtime lookup of variables by the JASS virtual machine, having a lot of variables will decrease the average lookup performance. This is because the hashtable used has a finite bucket count and so more variables will result in more collisions which will add a O(n) like performance factor to variable lookup.

Is it noticeable? For hundreds of thousands of variables quite possibly as the overhead might become significant enough that some systems relying on a lot of variable lookup or assignment might start to perform poorly. That said within the average map use case such number of variables are unlikely. In worst case if it is a problem caused by non-array variables one could write a tool to automatically translate several thousands of such variables into a single array by assigning them each a unique static index.
 
Status
Not open for further replies.
Back
Top