iOS内存使用量增加,找不到罪魁祸首 [英] iOS memory usage increasing, can't find the culprit
问题描述
我正在尝试使用AFNetworking 2.5下载大量图像并将它们传输到磁盘。根据Xcode中的内存监视器,这会导致无限制的内存增长(最终导致内存警告和强制退出) - 但使用分配工具分析内存使用情况会显示内存使用情况稳定。
I'm attempting to download a large number of images using AFNetworking 2.5 and stream them to disk. According to the memory monitor in Xcode, this is causing unbounded memory growth (and eventually memory warnings and force quits) - but profiling the memory usage using the allocations instrument shows the memory usage to be stable.
我想在这里认为Xcode是错的,但是为什么我的应用会被iOS杀死?
I'd like to think Xcode is just wrong here, but then why would my app be getting killed by iOS?
乐器显示这个 - 峰值是核心数据查询,其余是图像下载 - 峰值大约9.5MB,其余大约8.5MB
Instruments shows this - the peaks are Core Data queries, then the rest is the images downloading - peaks at about 9.5MB, the rest sits at about 8.5MB
我也试过了快照分析 - 显示了一点点增长但是远不及Xcode报告的金额
I've also tried Heapshot Analysis - which shows a tiny bit of growth but nowhere near the amount reported by Xcode
Xcode的内存监视器显示了这一点 - 每次迭代增加了多个MB。
Xcode's memory monitor shows this - growing by multiple MB per iteration.
有没有办法让乐器向我展示Xcode看到的东西?或者有没有更好的工具来找出所有这些内存的去向?
Is there any way to get Instruments to show me whatever Xcode is seeing? Or is there a better instrument to use to find out where all this memory is going?
谢谢!
推荐答案
根据Xcode中的内存监视器,这会导致无限制的内存增长(最终导致内存警告和强制退出) - 但使用分配工具分析内存使用情况显示内存使用情况稳定。
According to the memory monitor in Xcode, this is causing unbounded memory growth (and eventually memory warnings and force quits) - but profiling the memory usage using the allocations instrument shows the memory usage to be stable.
相信仪器和分配信息 - 不内存监视器Xcode中。内存监视器图表完全不相关。忽略它。
Believe Instruments and the Allocations information - not the memory monitor in Xcode. The memory monitor graph is completely irrelevant. Ignore it.
这不是因为Xcode中的内存监视器无用或错误。这是因为内存管理对于调试版本而言与完全不同于版本构建(Instruments使用版本构建)。在Swift中尤其如此(你没有说你是否使用Swift)。
This is not because the memory monitor in Xcode is useless or wrong. It is because memory management is completely different for a debug build than for a release build (Instruments uses a release build). This is especially true in Swift (you don't say whether you're using Swift).
观察设备上的内存使用仅发布版本中仅 。否则,你将被完全误导。
Observe memory usage only on the device and only in a release build. Otherwise, you'll be completely misled.
这篇关于iOS内存使用量增加,找不到罪魁祸首的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!