我应该如何解释“所有分配”?泄漏仪器中的数据?

发布于 2024-09-24 02:20:50 字数 196 浏览 7 评论 0原文

我编写了一个应用程序,并正在测试它的内存泄漏,当我注意到每当我打开和关闭子视图时,泄漏模拟器中的“所有分配”类别都会不断增加其大小。

我最初认为这是内存泄漏,但它并没有在泄漏选项卡中显示为泄漏。

这是正常的吗?

模拟器的屏幕截图

I have written an app and was testing it for memory leaks when I noticed that the "all allocations" category in the leaks simulator keeps increasing its size whenever I open and close a sub-view.

I intially thought it was a memory leak, but it does not show up as a leak in the leaks tab.

Is this normal?

Screenshot of the simulator

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

如果没有你 2024-10-01 02:20:50

这取决于您正在查看表格的哪一列。

“总体”和“总体字节”数字始终会上升,因为它们是在不考虑释放的情况下进行的分配的运行计数。

然而,当对象或内存块被分配时,“Live Bytes”和“# Living”数字应该上升,但当它们被释放时,“Live Bytes”和“# Living”数字应该下降。

重复打开和关闭子视图应该(根据图像或数据缓存)悬停在固定数量的活动字节和活动对象/内存块周围。

然而,正如您从屏幕截图中看到的那样,仪器有时会有点混乱。整个“# Transitory”列显示“0”,这显然是不正确的。临时对象只是一个已被分配并随后被释放的对象,即它是一个非生命对象。

(# Living + # Transitory == # 总之)

每当 Instruments 给我那一列零时,我就会退出当前运行并开始新的运行。

至于Leaks Instrument,它只会显示那些不再有任何指针指向它们的对象或内存块。如果程序不断分配越来越多的对象/内存块但保留指向它们的指针,则泄漏仪器将不会显示它们。

It depends which column of the table you are looking at.

The 'Overall' and 'Overall Bytes' figures will always go up, since they are a running count of allocations made with no account of deallocations.

However, the 'Live Bytes' and '# Living' figures should go up when an object or block of memory has been allocated, but should go down when they are deallocated.

Repeatedly opening and closing a sub-view should (subject to image or data caching) hover around a fixed number of live bytes and living objects / memory blocks.

Instruments sometimes gets a bit confused, however, as you can see from the screenshot. The whole '# Transitory' column is showing '0', which is obviously incorrect. A transitory object is just one that has been allocated and subsequently deallocated, i.e. it's a non-living object.

(# Living + # Transitory == # Overall)

Whenever Instruments gives me that column of zeros, I quit the current run and start a new one.

As for the Leaks Instrument, it will only show those objects or memory blocks that no longer have any pointers pointing to them. If a program continually allocates more and more objects / memory blocks but retains pointers to them, the Leaks Instrument won't show them.

猫七 2024-10-01 02:20:50

这很有意义,不是吗?每次您在应用程序中执行某些操作时,可能会分配一些内容,例如不同的子视图。因此总分配量会增加。这只是总分配量的记录。

That would make sense would it not? Every time you do something in the app, something is probably allocated such as your different subviews. Therefore total allocations will increase.It's just a record of the total allocations.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文