• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[JASS] Arrays

Status
Not open for further replies.
Level 6
Joined
May 7, 2009
Messages
228
Do arrays take up space for the full 4096 elements, even if you don't use them?

For example, suppose you had an array, but you only used the first 6 values. Would it still take up 16kb worth of space?

If so, is it better to combine arrays to use less space? For example, instead of using 7 arrays with 6 elements each, use one array with 42 elements?
 
8191 elements to be precise.

And it's pretty unclear to me if it allocates memory for all elements from the start. Some say it drectly uses 8191 elements (32kb), others say that it's allocated in chunks of 256 (2kb)...

32kb isn't a big deal anyway. Nothing compared to what 1 leak does in a periodic trigger.
 
It actually allocates the closest 2 to power of n. ex: 1,2,4,8,16,32,64,128...

And there are 8192 slots, you also have to count the 0.
 
Status
Not open for further replies.
Back
Top