If I zero the number of elements in an array by setting its length to 0, does this also release the memory used by the pre-existing array elements?
Announcement
Collapse
No announcement yet.
Does array.length = 0 free storage?
Collapse
X
-
Thanks for the suggestion. I tried this:
var Araay = new Array();
Array[100] = "Y";
Araay = null;
Array[100] = "Y";
On the last statement, I get "Araay has no properties". It seems that setting the entire array to null loses its Array quality.
But it's OK, I've found that by setting each of the individual existing elements to null avoids the "out of memory" problem that happens when I try using:
Araay.length = 0
Thanks!
Comment
-
almerger
Another thing you could try is to create a new Array with the same name and no parameters eg
PHP Code:var myArray = new Array(1,2,3,4,5);
debugPrint(myArray.length)
myArray = new Array();
debugPrint(myArray.length)
Alex
Comment
Comment