I Inman Well-Known Member Licensed User Longtime User May 1, 2013 #1 Suppose I declare an array A(1000) as String but use only 200 of it. Will the memory and other resources be allocated for the whole array of 1000 (right when the Dim statement is called) or is it allocated one at a time for each array item when you first use it?
Suppose I declare an array A(1000) as String but use only 200 of it. Will the memory and other resources be allocated for the whole array of 1000 (right when the Dim statement is called) or is it allocated one at a time for each array item when you first use it?
agraham Expert Licensed User Longtime User May 1, 2013 #2 The space for the entire array is allocated when you Dim it. However for a String array the array only contains the references to the individual String elements and not the Strings themselves. All the references in a newly created String array point to an empty String. The space for a String is allocated when the String is created. In general you shouldn't need to be concerned about memory unless you are dealing with large Bitmaps. Android will take care of managing memory for you. Upvote 0
The space for the entire array is allocated when you Dim it. However for a String array the array only contains the references to the individual String elements and not the Strings themselves. All the references in a newly created String array point to an empty String. The space for a String is allocated when the String is created. In general you shouldn't need to be concerned about memory unless you are dealing with large Bitmaps. Android will take care of managing memory for you.
I Inman Well-Known Member Licensed User Longtime User May 1, 2013 #3 That clears it. Thank you. Upvote 0