HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

What does the array size?

01-23-2004, 06:20 PM#1
Soultaker
Hi I would like to now what the array size does...
01-23-2004, 06:28 PM#2
Spinally
It says how much values there can be stored in that variable.
For example:

in the unit variable OneUnit you can store one unit.
in the unite array variable ThreeUnits with array size 3 you can store 3 units: ThreeUnits[1]
ThreeUnits[2]
ThreeUnits[3]


note: actually you can store 4 in them: ThreeUnits[0], but that seems to confuse people.
01-23-2004, 06:48 PM#3
weaaddar
Actually hes wrong. It sets up the amount of defined elements in an array.

An array in jass will always use 8192 elements. No matter if your only using 1 or 400. Its very bad to use arrays that you do not need to use. As each type in war3 uses a 4kb integer as its pointer. So you are using roughly 32kb of ram per array. Sure it doesn't seem like much but remember that types also have there own memory usage on the handling stack.
01-24-2004, 06:50 AM#4
Soultaker
Are you saying that I shouldset my array size to 1 even when I got 12 units?
01-24-2004, 10:07 AM#5
AIAndy
You can, the array size only matters for types that need to be initialized like groups, dialogs and similar, or if you want to initialize the array with a value.

@Weaddar: Are you sure that always a full array is used?
01-24-2004, 02:00 PM#6
weaaddar
I'm pretty positive it does. You can try a test trigger where you create several hundred local arrays when you type a message and have a long trigger sleep action so you can document memory usage if you'd like.

I think in terms of array effeicency you always want to set up arrays in unfragmented lengths of memory. And since war3 arrays are not dynamic but fixed in elemental length it only stands to reason if the programmers were worth there salt that when you use an array it sets up a congenous 32 kb of ram (8kb in RoC)