0

I'm really struggling with memory management in iOS or more precisely monitoring complex memory usages.

So actually I'm wondering about the allocations instrument provided once in Zombie-Mode (when I'm looking for zombies) and in general the "normal" allocations instrument (chosable from Memory->Allocations).

If I'm searching for Zombies the allocations instrument shows me completely different numbers of storage allocated at the moment (live Bytes). With every click on my UI the live bytes are increasing a lot.

But in the normal allocations window (Memory->allocations) everything seems to be (almost absolutely) fine. So, 1,13 MB of live bytes are allocated, but this is the maximum of allocated bytes in contrast to the description above where I can reach 4-5 MB with some clicks on my UI. So it seems really weird for me.

Is there something more count in Zombies->Allocations which is not regarded in the normal allocations-window?

Note: There are no zombies and leaks in my program.

4

1 回答 1

2

据我了解 Zombies 功能,它被视为与 Instruments 中的泄漏和对象分配互斥的。

事实上,当您启用僵尸(Instruments 或 NSZombies 指令)时,会发生什么是对象的“正常”保留周期被欺骗,以便您可以检测使用已被释放的对象的尝试。从某种意义上说,我不知道有关它的详细信息,但这就像如果保留计数增加 1,并且当保留计数变为 1 时,您会收到有关尝试使用已释放实例的错误. 事实上,如果保留计数可能变为零,则对象将被释放,并且在大多数情况下无法检测到重用尝试,因为它可能在释放后很长时间发生,并且该块内存可能已经重新分配给其他对象。因此保留计数的人为增加将有助于允许对象在其“

这只是我的心智模型,但它允许我解释为什么启用僵尸时内存分配要高得多(即,因为对象没有像在正常情况下那样被释放)。

于 2011-07-02T15:15:00.870 回答