objective-c Instruments ObjectAlloc:活字节数和总字节数说明

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2154219/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 22:50:40  来源:igfitidea点击:

Instruments ObjectAlloc: Explanation of Live Bytes & Overall Bytes

iphoneobjective-cxcodeinstruments

提问by Ross

I'm using Instument's ObjectAlloc tool in an attempt to understand what the memory my application (iPhone) is doing and when and where it is doing it.

我正在使用 Instument 的 ObjectAlloc 工具试图了解我的应用程序 (iPhone) 正在执行的内存操作以及它在何时何地执行此操作。

I would really like a basic explanation of these statistics:

我真的很想对这些统计数据做一个基本的解释:

  • Live Bytes
  • Living

  • Transitory

  • Overall Bytes
  • 实时字节
  • 生活

  • 暂时的

  • 总字节数

When I am trying to work out how much memory my application is using, am I to look at Live Bytes or Overall Bytes? Does this include leaked memory? What are Transitory objects?

当我试图计算我的应用程序使用了多少内存时,我应该查看实时字节数还是总字节数?这包括泄漏的内存吗?什么是临时对象?

Thanks

谢谢

回答by Ken Aspeslagh

ObjectAlloctracks all memory allocation and deallocation over the time your program is running.

ObjectAlloc跟踪程序运行期间的所有内存分配和释放。

The Living bytes, or Net bytesis how much memory your application is using at the time you select in the timeline. That will include leaked memory, since leaked memory is never deallocated.

Living bytes, or Net bytes是您的应用程序在您在时间线中选择的时间使用的内存量。这将包括泄漏的内存,因为泄漏的内存永远不会被释放。

#Livingis how many allocations of a certain size/object type happened (and are still allocated). This is very useful when looking for leaks.

#Living是发生了多少特定大小/对象类型的分配(并且仍在分配)。这在查找泄漏时非常有用。

For example, if you repetitively perform an action (like coming in an out of a modal view controller), and you see that #Livingof an object grows by the same amount each time, then you're probably leaking those objects. You can then confirm by drilling down and seeing the exact line of code that is allocating the objects, and even see the time index each one was created.

例如,如果您重复执行一个动作(例如从模态视图控制器中进入),并且您看到#Living对象每次都以相同的量增长,那么您可能正在泄漏这些对象。然后,您可以通过深入查看分配对象的确切代码行进行确认,甚至可以查看每个对象的创建时间索引。

Overall bytesincludes memory that has been released. It's useful to track that number for performance optimization purposes, but not if you're just trying to see your current memory footprint or look for leaks.

Overall bytes包括已释放的内存。出于性能优化的目的跟踪该数字很有用,但如果您只是想查看当前的内存占用量或查找泄漏则不然。

回答by Pranav Jaiswal

Stats explanation from apple docs. Link to the document

来自苹果文档的统计解释。 文件链接

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明