iOS 10 Quicklook 内存使用
iOS 10 Quicklook Memory Usage
当我将一些图像加载到我的 QuicklookController 时,内存管理永远不会释放已使用的内存。例如:
override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
let photoFile = photos[indexPath.row] as Photo
currentFilePath = photoFile.filePath
let preview = QLPreviewController()
preview.dataSource = self
self.navigationController?.pushViewController(preview, animated: false)
}
func documentsDirectoryURL() -> NSURL {
let manager = NSFileManager.defaultManager()
let URLs = manager.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
return URLs[0]
}
func previewController(controller: QLPreviewController, previewItemAtIndex index: Int) -> QLPreviewItem {
return documentsDirectoryURL().URLByAppendingPathComponent(currentFilePath)
}
这里我加载图片。图像大小约为 200kbytes,大小约为 2500x1250 像素。内存增加了大约 10 Mbytes,但是当我关闭控制器(后退按钮)时,内存仍在使用。因此,每次点击都会花费 10 MB 的额外 RAM(图像是否相同或新图像无关紧要)
如何强制 QLPreviewController
释放已用内存?
编辑:这似乎已经被报道过:
https://github.com/jcamiel/radars/blob/6b02382c08cdd9312df325a7a08ea9efeec5727b/28318213/radar.md
https://forums.developer.apple.com/thread/63020
编辑2:
现在使用 2 iPad Pro 9.7
进行测试
首先,iOS 10.0.1 -> 如上所述内存增加。
其次,iOS 9.3.5 -> 没有内存问题
看来它真的只是一个 iOS 10 个错误...
似乎用 iOS 10.0.2
修复了
当我将一些图像加载到我的 QuicklookController 时,内存管理永远不会释放已使用的内存。例如:
override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
let photoFile = photos[indexPath.row] as Photo
currentFilePath = photoFile.filePath
let preview = QLPreviewController()
preview.dataSource = self
self.navigationController?.pushViewController(preview, animated: false)
}
func documentsDirectoryURL() -> NSURL {
let manager = NSFileManager.defaultManager()
let URLs = manager.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
return URLs[0]
}
func previewController(controller: QLPreviewController, previewItemAtIndex index: Int) -> QLPreviewItem {
return documentsDirectoryURL().URLByAppendingPathComponent(currentFilePath)
}
这里我加载图片。图像大小约为 200kbytes,大小约为 2500x1250 像素。内存增加了大约 10 Mbytes,但是当我关闭控制器(后退按钮)时,内存仍在使用。因此,每次点击都会花费 10 MB 的额外 RAM(图像是否相同或新图像无关紧要)
如何强制 QLPreviewController
释放已用内存?
编辑:这似乎已经被报道过:
https://github.com/jcamiel/radars/blob/6b02382c08cdd9312df325a7a08ea9efeec5727b/28318213/radar.md
https://forums.developer.apple.com/thread/63020
编辑2:
现在使用 2 iPad Pro 9.7
进行测试首先,iOS 10.0.1 -> 如上所述内存增加。 其次,iOS 9.3.5 -> 没有内存问题
看来它真的只是一个 iOS 10 个错误...
似乎用 iOS 10.0.2
修复了