Hi, I am developing an application in which I need a chache of 50 images (the size of all images is 2.5 MB). It caches images and also increases the memory by 10 MB in the Apple Watch application, which is why the application crashes.Xcode gives an error in xCode "Message from the debugger: terminated due to a memory error"
The code I'm using is below:
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)
Also a screenshot of the memory allocation and memory leak:

Please help, thanks in advance.
source
share