lundi 2 mars 2015

iOS 8 Memory leak using String in Swift

I found the memory leak problem when working with String (NSString) methods for composing and extraction (eg. stringByAppendingPathComponent, lastPathComponent).


I created a sample loop (see code below), and when I run it on the simulator and the device memory is not released. It takes gigabytes! Even after the end of the loop memory does not decrease.


I tried to use autoreleasepool {} without success.


Does anyone have an idea why this is happening and how to remedy this?


I'm working on Xcode 6.3 beta



func memoryLeakTest() {

for _ in 1...1000000 {

let url = NSURL(scheme: "http", host: "google.com", path: "/")!.URLByAppendingPathComponent("subpath")

let path = url.path
}
}

Aucun commentaire:

Enregistrer un commentaire