iPhone:Xcode、仪器、内存分配。什么是合理的?
我正在使用仪器来分析我正在开发的 iPhone 应用程序中的内存使用情况。我想知道,合理的内存分配大小是多少?
当我获得有关目标的信息时,我是否应该选中复选框以忽略“NS”、“CF”和“Malloc”前缀?当我不忽略它们时,我在启动时得到的总字节值似乎相当大,约为 47MB,尽管活动字节仅为 6MB 左右。当我忽略前缀时,我将获得大约 1MB 的总体数据和 350KB 的实时数据。忽略或不忽略前缀的好理由是什么?这里,总体字节和活动字节之间有什么区别?
最后,如果需要的话,我可以通过哪些方式来减少应用程序的内存占用?
I'm using instruments to analyze my memory usage in an iPhone app I am developing. I was wondering, what is a reasonable memory allocation size?
When I get info on my target, am I suppose to check the boxes to ignore "NS", "CF", and "Malloc" prefixes or not? When I don't ignore them I get what seems like a pretty large value for overall bytes at startup of around 47MB, although live bytes is only about 6MB. When I do ignore the prefixes, I'll get about 1MB overall, and 350KB live. What would be a good reason to ignore or not ignore the prefixes? What is the difference, here, between overall and live bytes?
And lastly, in what ways can I go about decreasing my application's memory footprint, if need be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
忽略 NS、CF 或 Malloc 的复选框仅允许您过滤到总分配的不同子集。是否检查它们取决于您要查找的内容。显然,不检查它们可以让您获得最全面的视图,但如果您正在寻找特定的内容,您可能需要忽略其他类别。
“实时”数据是尚未发布的数据,而“总体”数据是您曾经分配的所有数据,即使它已经发布。
请注意,“分配”工具仅向您提供已使用的堆内存的视图。这是相当狭窄的。您的应用程序还直接或间接地将内存用于其他用途。此外,内存碎片可能会导致您的总内存使用量比分配工具中显示的要高得多,因为操作系统以 4k 页的形式提供内存。
您应该使用 VM Tracker 工具来查看应用程序的总内存使用情况。
The check boxes to ignore NS, CF, or Malloc merely allows you to filter down to different subsets of the total allocations. Whether or not you check them depends on what you're looking for. Obviously, leaving them all unchecked gives you the most comprehensive view, but if you're looking for something specific, you may want to ignore the other categories.
The "Live" data is what hasn't been released, whereas "overall" is everything you've ever allocated, even if it has been released.
Be aware that the "Allocations" tool only gives you a view of the heap memory you've used. This is pretty narrow. Your app uses memory for directly and indirectly for other things as well. In addition, memory fragmentation can cause your total memory usage to be much higher than it appears in the allocations tool, since memory is provided in 4k pages by the OS.
You should use the VM Tracker tool to see your apps total memory usage.