如何知道 Instruments 中那些蓝色块到底是什么?

发布于 2024-12-07 05:37:43 字数 330 浏览 0 评论 0原文

我正在使用 Instruments 来查找应用程序中的内存泄漏。 当对象分配时,Instrument 中会显示一个蓝色块(线),如下所示:

Instruments 时间轴的屏幕截图,显示Allocations 图 http://naituw.com/temp/instruments.png

当对象被释放时,蓝线将会消失。

但是,当我在应用程序中进行某些操作时,一些蓝色块留在那里,并没有消失,我如何知道这些块实际上在内存中是什么?谢谢!

I am using Instruments to find memory leaks in my app.
When a object alloc, a blue block(line) display in Instrument, like this:

Screenshot of Instruments's timeline, showing the Allocations graph http://naituw.com/temp/instruments.png

When the object have been release, the blue line will disappear.

But when I make some operation in my application, some blue block left there, doesn't disappear, How can I know what those block actually is in the memory? Thanks!

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

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

发布评论

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

评论(2

↘人皮目录ツ 2024-12-14 05:37:43

选择仪器并查看窗口下半部分的列表。它将显示一个表格或大纲(取决于仪器),列出仪器记录的内容。

对于分配工具,它列出了您的应用程序已分配的内容。根据视图设置,它们可能是仍然活动的对象或所有对象,甚至是您已释放的对象。

对于泄漏工具,它列出了您的应用程序已分配和泄漏的内容(即不再有任何引用)。请注意,您可能仍然在永远不会使用的东西上浪费越来越多的内存,不是因为您没有对它的引用,而是因为它位于只写缓存中(您将其隐藏但从不查找它)或类似情况。比尔·邦加纳(Bill Bumgarner)称之为“被遗弃的记忆”。

使用任一工具,您都可以单击列表中的 ➲ 按钮进行更深入的研究,查看给定类型的分配列表(例如,所有 NSImage)或单个对象从出生到死亡发生的所有事情。后者对于查找泄漏和过度释放崩溃非常有用,这也是 Instruments 的 Zombies 模板比 NSZombieEnabled 好得多的原因。

Select the instrument and look in the list in the lower half of the window. It will show a table or outline (depending on the instrument) listing what the instrument recorded.

For the Allocations instrument, it lists things your application has allocated. Depending on the view settings, they may be objects that are still alive or all objects, even those that you have freed.

For the Leaks instrument, it lists things your application has allocated and leaked (i.e., no longer has any reference to). Note that you might still be wasting ever-increasing amounts of memory on things you will never use, not because you don't have a reference to it but because it's in a write-only cache (you stash it but never look it up) or similar situation. Bill Bumgarner calls this “abandoned memory”.

With either instrument, you can click on ➲ buttons within the list to drill deeper down into it, to see the list of allocations of a given type (e.g., all NSImages) or everything that happened to a single object, from birth to death. The latter is extremely useful for hunting down both leaks and over-release crashes, and is the reason why Instruments's Zombies template is so much better than NSZombieEnabled.

看海 2024-12-14 05:37:43

在泄漏工具中,这些显示了在特定时间发生的内存分配。

In leaks instrument these shows the memory allocations that took place at the particular time.

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