嗨,我正在開發一個應用程序,我需要chache 50個圖像(所有圖像的大小爲2.5 mb),這是chaching的圖像,但也增加了10 MB的內存Apple Watch App因應用程序崩潰。觀看套件應用程序:由於內存錯誤而終止
Xcode中給出xcode的錯誤「消息從調試器:終止,因爲該存儲器的錯誤」
我使用的代碼如下:
for (var i : Int = 1; i<26; i++) {
let filenameHuman = NSString(format: "human_%d", i)
let filenameZombie = NSString(format: "zombie_%d", i)
var imageHuman : UIImage! = UIImage(named: filenameHuman as String)
var imageZombie : UIImage! = UIImage(named: filenameZombie as String)
WKInterfaceDevice.currentDevice().addCachedImage(imageZombie, name: filenameZombie as String)
WKInterfaceDevice.currentDevice().addCachedImage(imageHuman, name: filenameHuman as String)
}
NSLog("Currently cached images: %@",WKInterfaceDevice.currentDevice().cachedImages)
也是存儲器分配和存儲器泄漏的屏幕截圖是:
請幫幫忙,先謝謝了。
這不會解決它,但可能會有所幫助https://developer.apple.com/library/ios/qa/QA1894/_index.html – Frans
你有沒有深究過這一點。我有完全相同的問題。每次調用WKInterfaceDevice.currentDevice()。addCachedImage()時內存都會上升,直到AwakeWithContext完成後纔會釋放內存。 –
@BrettHannah我在AwakeWithContext完成後使用上面的代碼,當我回彈時,內存不被釋放。 ? –