• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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?
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
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.
 
Level 3
Joined
Aug 9, 2008
Messages
60
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.
Top