Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 months ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
你说“我的对象没有被我的任何代码释放”。我发现在 Objective-C 中,遇到代码没有显式释放对象但对象已经被释放的情况并不少见。例如,在我的脑海中,假设您有一个对象 #1,其保留计数为 1,您释放了它,但随后意外地自动释放了它。然后,在自动释放池实际耗尽之前,您分配一个新对象#2——这个新对象#2 可以分配在与对象#1 相同的地址,这并非不可想象。因此,当自动释放池随后被耗尽时,它会意外释放对象#2。
You say "My object is not released by any of my code". I've found that it's not uncommon in Objective-C to run into situations where your code has not explicitly released an object yet the object has been released all the same. For example, off the top of my head, let's say that you have an object #1 with retain count of 1 and you release it but then autorelease it accidentally. Then, before the autorelease pool is actually drained, you allocate a new object #2 -- it's not inconceivable that this new object #2 could be allocated at the same address as object #1. So when the autorelease pool is subsequently drained, it will release object #2 accidentally.
我最近遇到了完全相同的问题,但我不完全确定原因是相同的。我可以告诉你的是,是什么为我解决了这个问题(尽管我仍然对解决方案并不完全满意)。
最后,这似乎是一个编译器问题,这可能证实了其他人关于编译器优化的说法。
我正在使用 Xcode 4.0(内部版本 4A304a)。问题出在 LLVM 编译器 2.0 代码生成上。特别是一个关键:“优化级别”
调试被设置为“无”。
发布设置为“最快,最小”,
将发布更改为“无”修复了崩溃(同样,将调试更改为“最快,最小”导致应用程序在启动时崩溃)。
I had the exact same problem recently, however I am not entirely sure the cause is the same. What I can tell you though is what resolved the issue for me (although I'm still not entirely satisfied with the solution).
In the end, it seems like a compiler issue, and this might confirm what others have said about compiler optimization.
I am using Xcode 4.0 (build 4A304a). The issue was with LLVM compiler 2.0 Code Generation. One key in particular: "Optimization Level"
Debug was set to "None".
Release was set to "Fastest, Smallest"
Changing Release to "None" fixed the crash (and similarly changing Debug to "Fastest, Smallest" caused the app the crash on launch).
我建议您使用 NSZombieEnabled 来了解什么是导致内存访问错误。
否则我无法看到您的应用程序在不同设备/配置上的行为有何不同。
I recommend you to use NSZombieEnabled to find out what is causing a bad access to memory.
Otherwise I can't see how your app can behave diferently on different devices/configurations.
我可以建议将发布设置的优化级别更改为“无”。
我多次遇到同样的问题(使用不同的应用程序)并以这种方式解决。
I can propose to change optimization level of release settings to "None".
I met the same problem few times (with different apps) and solved it in this way.
我从未“解决”这个问题,但我确实找到了有问题的代码。我怀疑这一段 Quartz 代码中的某些内容导致了内核深处某处的缓冲区溢出 - 并且它只在 3G 上引起了问题。该部分的一些设置未包括在内,但这绝对是它发生的地方:
I never "solved" this but I did track down the offending code. I suspect that something in this segment of Quartz code was causing a buffer overrun somewhere deep inside the core - and it only caused a problem on 3G. Some of the setup for this segment is not included but this is definitely where it is happening: