从iOS 14开始,我的iOS应用程序会将此错误消息打印到控制台(作为第一条消息)。
AppName(5088,0x1064438c0) malloc: nano zone abandoned due to inability to preallocate reserved vm space.
在谷歌上搜索时,我找不到任何其他类似的问题,我也不知道是什么导致了这一问题。我运行的是一台iPhone XS Max,iOS 14.0.1,Swift 5。
发布于 2020-10-01 23:47:54
尝试到:设置活动方案(旁边的播放和停止按钮)和编辑方案和诊断,然后打开“线程消毒器”。在Thread Sanitizer打开的情况下,错误将被捕获,并且您将收到调试器中更具描述性的警告。如果描述为Swift访问竞赛,那么您应该在代码中使用线程安全屏障。
发布于 2021-10-19 20:51:54
我不知道您是如何构建代码的,但在我的例子中,我所做的就是在代码中添加了一个do try catch
。下面是一些内容:
static func fetchAlbumWithAsyncURLSession() async throws -> [Album] {
guard let url = URL(string: "https://itunes.apple.com/search?term=taylor+swift&entity=album") else {
throw AlbumsFetcherError.invalidURL
}
let (data, _) = try await URLSession.shared.data(from: url)
let iTunesResult = try JSONDecoder().decode(ITunesResult.self, from: data)
return iTunesResult.results
}
类似这样的东西:
static func fetchAlbumWithAsyncURLSession() async throws -> [Album] {
guard let url = URL(string: "https://itunes.apple.com/search?term=taylor+swift&entity=album") else {
throw AlbumsFetcherError.invalidURL
}
do {
let (data, _) = try await URLSession.shared.data(from: url)
let iTunesResult = try JSONDecoder().decode(ITunesResult.self, from: data)
return iTunesResult.results
} catch {
print("Request failed with error: \(error)")
return []
}
}
然后我得到了错误:D
诚挚的问候!
https://stackoverflow.com/questions/64126942
复制相似问题