Array in swift can grow dynamically according to the size, but it does not seem to be shrinking.
var x: [Int] = []
for i in 0...1000 {
x.append(i)
}
for i in reverse(1000...0) {
x.removeAtIndex(0)
}
The capacity of x remains large. I also tried removeLast() and copy it to a new variable, but does not seem to reduce the capacity.