How much memory does an array with one high index element use?
1 answer
If you assign an item 1_000_000
and each item is 4 bytes, that would be 4_000_004 bytes of memory. So, strictly speaking, the answer is "No" :-)
But less pedantic: the built-in arrays are guaranteed to be laid out sequentially in memory, so this assignment allocates at least one block of 4 x 1_000_001 = 4_000_004 bytes of memory. As Christoph said in his comment, if you want to make sure that this is all he will ever highlight, you need to make it a formed array. You will also receive bonuses for the upper bound.
+9
source to share