提问人:shahrukh21 提问时间:8/12/2020 最后编辑:Umair Afzalshahrukh21 更新时间:8/13/2020 访问量:66
尝试使用循环一次更新超过 300 个联系人时 CNMutableContact 内存泄漏的 MutableCopy
MutableCopy of CNMutableContact memory leak when try to update more than 300 contacts at once using loop
问:
我遇到了一次更新 300 多个联系人的问题。当我尝试将真实联系人的可变联系人映像更新为可变副本时,发生内存泄漏。
RAM使用率为1.4GB,然后是应用程序。这是我的代码。
if let mutableCopy = contact.mutableCopy() as? CNMutableContact {
ImageDownloader.default.downloadImage(with: URL(string: thumbnailImageURL)!) { result in
switch result {
case .success(let value):
queue.sync {
SVProgressHUD.show(withStatus: "loading 1")
//mutableCopy.imageData = compressedImage?.pngData()
mutableCopy.imageData = value.image.pngData() //self.returnCustomSizeImage(image: value.image).pngData()
mutableCopy.givenName = givenName
mutableCopy.phoneNumbers = [CNLabeledValue(label: self.responsedContactsArray[index2].label ?? "NO DOB", value: CNPhoneNumber(stringValue: "\(trimmedPhoneNumber)"))]
//mutableCopy.familyName = "🧑🏽💻"
saveRequest.update(mutableCopy)
do {
try AppDelegate.mContactStore.execute(saveRequest)
} catch let error {
SVProgressHUD.dismiss()
}
}
答: 暂无答案
上一个:不可变类型与可变类型
评论