“__NSAutoreleaseFreedObject():释放先前释放的对象”出乎意料
我不确定这是否是一个错误。代码编译良好(没有警告),但是当我输入方法时,本地值(NSMutableString)在调试器中显示以下内容:
__NSAutoreleaseFreedObject(): release of previously deallocated object
我没有收到异常,看起来字符串的内容(当时甚至没有分配)是 NSAutoReleaseFreedObject 警告。
这是怎么回事?
I'm not sure if this is an error or not. The code compiles fine (no warnings), but when I enter a method, a local's value (an NSMutableString) displays this content in the debugger:
__NSAutoreleaseFreedObject(): release of previously deallocated object
I'm not getting an exception, it looks like the contents of the string (which is not even allocated at that time) is that NSAutoReleaseFreedObject warning.
What's going on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你没有将普通的局部变量初始化为任何值,那么它的值是未定义的——它可以是任何值。实际上,它会将恰好位于变量分配的堆栈上的位模式解释为变量类型的值。在这种情况下,变量包含的“任何内容”恰好是该字符串的地址。
If you don't initialize a normal local variable to anything, its value is undefined — it could be anything. In practice, it will interpret the bit pattern that happens to lie on the stack where the variable is allocated as a value of the variable's type. In this case, the "anything" that the variable contains happens to be the address of that string.
它(可能)意味着您的应用程序的执行方式与平常不同,并且在对象的引用计数中暴露了一个错误。此类问题也可能与不正确的多线程有关。
执行您的应用程序以触发启用僵尸的问题应该可以帮助您找到它。
it (likely) means that your app has executed different from usual, and exposed a bug in your ref counting of the object. this type of issue can also be related to improper multithreading.
executing your app to trigger the problem with zombies enabled should help you locate it.