简体   繁体   English

autorelease 和 retain 导致消息发送到 deallocated 消息

[英]autorelease and retain causes message sent to deallocated message

I've been getting this random crash, in which I don't know how to reproduce again.我一直在遇到这种随机崩溃,我不知道如何再次重现。 It happens when I was browsing/using the apps for some time, switching views here and there and I got this:当我浏览/使用应用程序一段时间,在这里和那里切换视图时会发生这种情况,我得到了这个:

在此处输入图像描述

First of all I don't know which UIImage is this crash referring to.首先,我不知道这次崩溃指的是哪个 UIImage。 I do have a crash report, but I don't know how to read it.我确实有崩溃报告,但我不知道如何阅读它。 I would like to reproduce the error, but I don't know how to.. it seems that it's quite random.我想重现错误,但我不知道如何.. 似乎它很随机。 Can someone help me out in debugging this?有人可以帮我调试吗?

Without being able to reproduce the failure, it will be very hard.如果无法重现故障,那将非常困难。

If you cannot reproduce it, I would suggest building your project by using the Xcode option "Build and Analyze".如果您无法重现它,我建议您使用 Xcode 选项“构建和分析”来构建您的项目。 Indeed, since this is seemingly a problem with retain/release, "Build and Analyze" could give you some hint at where things go bad.事实上,由于这似乎是保留/释放的问题,“构建和分析”可以给你一些暗示 go 坏的地方。 By the way, if you are not doing it, it is highly suggested, almost mandatory check.顺便说一句,如果你不这样做,强烈建议,几乎是强制检查。

You could try and post the crash report, but I doubt it will be useful.您可以尝试发布崩溃报告,但我怀疑它是否有用。 The point is finding out where the UIImage is deallocated and why, the crash report refers to an attempt to use the UIImage after its release, so this would likely be in a different portion of your code.关键是找出 UIImage 被释放的位置以及为什么,崩溃报告是指在 UIImage 发布后尝试使用它,因此这可能位于代码的不同部分。

If you have some suspect as to which class contain this UIImage, you can post some code so that we can help you inspect it.如果您怀疑哪个 class 包含此 UIImage,您可以发布一些代码,以便我们帮助您检查它。

As a hopefully useful hint as to how to reproduce this issue, I would also suggest sending the simulator a Memory Warning.作为关于如何重现此问题的有用提示,我还建议向模拟器发送 Memory 警告。 Indeed, in such cases all UIViews that are not displayed are released and this could be the culprit with your UIImage.实际上,在这种情况下,所有未显示的 UIView 都会被释放,这可能是您的 UIImage 的罪魁祸首。 So, you send it and see if the crash happens again... just a hint, anyway...所以,你发送它,看看崩溃是否再次发生......无论如何,只是一个提示......

Hard to say something for sure.很难肯定地说什么。 This is my guess.这是我的猜测。

I see you are getting some data from an external source "convore.com".我看到您正在从外部来源“convore.com”获取一些数据。 When you say you get the error randomly, I think it may be due to the data received from the convore.com api.当您说您随机收到错误时,我认为这可能是由于从 convore.com api 收到的数据。 Probably from time to time you are not getting the image, link, or graphics from the server and you don't create and image, and then you are trying to retain it, causing the error.可能有时您没有从服务器获取图像、链接或图形,并且您没有创建图像,然后您试图保留它,从而导致错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM