- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
最初,我的应用程序因 BAD_EXEC_ACCESS 而崩溃。我打开了 NSZombieEnabled,输出如下。崩溃极其不一致,如果崩溃,它总是在三个地方之一崩溃,但在传递这些代码行时并不总是崩溃。 IE。有时它会在前 10 次用户交互中的其中一个地方崩溃,有时我可以按住控件(它通过这些代码行)超过一分钟,然后它最终崩溃。
NSZombieEnabled 的输出也不一致,如“崩溃位置 #2”中所述 - 两个 NSZombieEnabled 输出是应用程序在同一行代码上崩溃的示例,但具有不同的 NSZombieEnabled 输出。
我知道通常这种类型的错误意味着我过度释放了某些东西,但我无法弄清楚我做错了什么。
我遵循的内存管理规则是:
(我听说过与内存管理相关的“将 IBOutlets 设置为 nil”,但我没有找到如何完成此操作的充分描述,因此我的应用程序中没有这样做。)
如果我可以提供任何有帮助的其他信息,请告诉我。
提前致谢!抱歉,如果我太长太彻底(INTP)!
-罗本
下面是崩溃的一些输出记录。当崩溃发生时,它总是发生在这三个位置之一。这些位置是通过在崩溃后进行回溯并查找我编写的代码行号和文件来确定的。
崩溃位置#1:
if (![[self fetchedResultsController] performFetch:&error])
示例崩溃位置 #1 NSZombieEnabled 输出:
*** -[Not A Type release]: message sent to deallocated instance 0x3b3f570
崩溃位置#2:
NSMutableArray *tips = [NSMutableArray arrayWithArray: [[[categories objectAtIndex: indexPath.row] valueForKey:@"tips"] allObjects]];
示例崩溃位置 #2 NSZombieEnabled 输出:
*** -[CFArray retain]: message sent to deallocated instance 0x3e53990
*** -[NSFetchRequest retain]: message sent to deallocated instance 0x3b2f2c0
崩溃位置#3:
NSMutableArray *tips = [NSMutableArray arrayWithArray: [[[justOneCategory objectAtIndex: 0] valueForKey:@"tips"] allObjects]];
示例崩溃位置 #3 NSZombieEnabled 输出:
*** -[UIViewControllerWrapperView retain]: message sent to deallocated instance 0x3e593a0
示例回溯(这对应于第 3 行):
#0 0x01d6a3a7 in ___forwarding___ ()
#1 0x01d466c2 in __forwarding_prep_0___ ()
#2 0x01cfd988 in CFRetain ()
#3 0x01cfd495 in CFArrayCreate ()
#4 0x01d406c3 in -[__NSPlaceholderArray initWithObjects:count:] ()
#5 0x01d5d34a in +[NSArray arrayWithObjects:count:] ()
#6 0x01d6386e in -[NSSet allObjects] ()
#7 0x00003bbc in -[RootViewController getRandomTip:] (self=0x3b24ea0, _cmd=0x7447, sender=0x3b38330) at /Users/***/Classes/RootViewController.m:36
#8 0x00299405 in -[UIApplication sendAction:to:from:forEvent:] ()
#9 0x002fcb4e in -[UIControl sendAction:to:forEvent:] ()
#10 0x002fed6f in -[UIControl(Internal) _sendActionsForEvents:withEvent:] ()
#11 0x002fdabb in -[UIControl touchesEnded:withEvent:] ()
#12 0x002b2ddf in -[UIWindow _sendTouchesForEvent:] ()
#13 0x0029c7c8 in -[UIApplication sendEvent:] ()
#14 0x002a3061 in _UIApplicationHandleEvent ()
#15 0x0252ed59 in PurpleEventCallback ()
#16 0x01d41b80 in CFRunLoopRunSpecific ()
#17 0x01d40c48 in CFRunLoopRunInMode ()
#18 0x0252d615 in GSEventRunModal ()
#19 0x0252d6da in GSEventRun ()
#20 0x002a3faf in UIApplicationMain ()
#21 0x00002a60 in main (argc=1, argv=0xbfffef9c) at /Users/***/main.m:14
编辑:添加 Griffo 请求的一些附加代码和输出
感谢您的回复,重新编写更多具体的代码是否会有帮助?现在,这是包含崩溃位置 #1 和崩溃位置 #2 的完整方法。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == ALLTIPS_SECTION) {
self.tipsController.title = @"Tips";
NSError *error = nil;
if (![[self fetchedResultsController] performFetch:&error]) {
// NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
// abort();
}
self.tipsController.tips = [NSArray arrayWithArray: [fetchedResultsController fetchedObjects]];
} else {
self.tipsController.title = [[categories objectAtIndex: indexPath.row] name];
NSMutableArray *tips = [NSMutableArray arrayWithArray: [[[categories objectAtIndex: indexPath.row] valueForKey:@"tips"] allObjects]];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending: YES];
[tips sortUsingDescriptors: [NSArray arrayWithObject: sortDescriptor]];
[sortDescriptor release];
self.tipsController.tips = [NSArray arrayWithArray: tips];
}
[self.navigationController pushViewController:self.tipsController animated:YES];
}
我没有在您询问的特定崩溃上运行 malloc_history,但我确实在 #3 上运行了它,这里是输出,我不知道应该如何解析它,所以任何建议都会有帮助(总之)我读过的关于 malloc_history 的教程显示了输出,它们都像“它就在那里”,而我则想“在哪里?你在看什么”):
ALLOC 0x3b55130-0x3b5516f [size=64]: thread_a0a3f500 |start | main | UIApplicationMain | GSEventRun | GSEventRunModal | CFRunLoopRunInMode | CFRunLoopRunSpecific | PurpleEventCallback | _UIApplicationHandleEvent | -[UIApplication sendEvent:] | -[UIWindow _sendTouchesForEvent:] | -[UIControl touchesEnded:withEvent:] | -[UIControl(Internal) _sendActionsForEvents:withEvent:] | -[UIControl sendAction:to:forEvent:] | -[UIApplication sendAction:to:from:forEvent:] | -[RootViewController getRandomTip:] | -[_NSFaultingMutableSet allObjects] | -[_NSFaultingMutableSet willRead] | -[NSManagedObjectContext(_NSInternalAdditions) _retainedObjectWithID:optionalHandler:withInlineStorage:] | +[NSManagedObject(_PFDynamicAccessorsAndPropertySupport) allocWithEntity:] | _PFAllocateObject | malloc_zone_calloc
----
FREE 0x3b55130-0x3b5516f [size=64]: thread_a0a3f500 |start | main | UIApplicationMain | GSEventRun | GSEventRunModal | CFRunLoopRunInMode | CFRunLoopRunSpecific | __CFRunLoopDoObservers | _performRunLoopAction | -[_PFManagedObjectReferenceQueue _processReferenceQueue:] | _PFDeallocateObject | malloc_zone_free
ALLOC 0x3b55130-0x3b55153 [size=36]: thread_a0a3f500 |start | main | UIApplicationMain | GSEventRun | GSEventRunModal | CFRunLoopRunInMode | CFRunLoopRunSpecific | __CFRunLoopDoObservers | CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) | CA::Transaction::commit() | CA::Context::commit_transaction(CA::Transaction*) | CALayerLayoutIfNeeded | -[CALayer layoutSublayers] | -[UILayoutContainerView layoutSubviews] | -[UINavigationController _startDeferredTransitionIfNeeded] | -[UINavigationController _startTransition:fromViewController:toViewController:] | +[UIViewControllerWrapperView wrapperViewForView:frame:] | +[NSObject alloc] | +[NSObject allocWithZone:] | _internal_class_createInstance | _internal_class_createInstanceFromZone | calloc | malloc_zone_calloc
最佳答案
需要注意的几件事:
首先,关于“设置为零”,这是一个很好的做法。任何时候你释放一些东西,立即将其设置为零。这意味着 -dealloc 通常看起来像这样(或十几种其他带有分号、两行等的样式):
[_foo release], _foo = nil;
但我怀疑这是你的问题。在您发送的 malloc_history 中,它显示有问题的对象是 NSManagedObject,因此它是 Core Data 之外的东西。确保您已阅读Memory Management Using Core Data文档。
如果您有 10.6,那么我强烈推荐静态分析器。按 Cmd-Shift-A,它会查找明显的内存错误。我发现它非常擅长。
关于iphone - 由于 iPhone 应用程序中的 "message sent to deallocated instance"导致崩溃不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2367739/
我可以同步我的 Gmail 收件箱,但发送的文件夹不起作用。 这是我的 .mbsyncrc IMAPStore martinstabenfeldt-remote Account martins
我正在尝试从 nodeJS 发送电子邮件(使用 nodemailer 库),目前我在整个邮寄过程中遇到了一些超时问题。那不是我需要帮助的问题。我确实需要帮助的问题是,当它到达日志记录部分时,成功将为空
我在 WordPress 模板中使用 Contact Form 7 插件。我创建了表单和相关的 CSS,所以一切正常。当我单击发送按钮并成功发送电子邮件时,我需要执行以下操作。表单应该消失并显示“已发
我正在从辅助角色向服务总线队列发送消息。我注意到一些消息会随机丢失。 当我调试时,我在 Send 方法之后设置了一个断点,并登录到我的 Azure 面板以检查消息队列是否增加。我发现奇怪的是,有时消息
我是网站安全的新手,目前正在尝试深入了解同源策略。虽然在 stackoverflow 和其他地方有关于 SOP 概念的非常好的帖子,但我找不到关于 chrome 和其他浏览器是否允许跨域 XHR po
我正在从官方文档中学习 Solidity,并在我创建简单硬币的练习中进行堆栈: pragma solidity ^0.4.20; // should actually be 0.4.21 con
我们有一个需求,其中服务器需要将数据推送到各个客户端。所以我们继续使用 SSE(服务器发送事件)。我浏览了文档,但仍然不清楚这个概念。我有以下疑问: 场景 1。假设有 10 个客户。所以所有 10 个
我对 javascript/jquery 缺乏经验。我正在阅读 http://api.jquery.com/mouseover/ 的文档其中指出: The mouseover event is sen
所以我理解服务器发送事件的概念( EventSource ): 客户端通过 EventSource 连接到端点 客户端只监听从端点发送的消息 我感到困惑的是它在服务器上的工作方式。我看过不同的例子,但
我看过 here和 there尝试弄清楚服务器发送的事件是在传输级别。我还不确定。 两个消息来源都声称它们“只是 http”。然而,至少有两种方式可以解释这样的陈述。 当我第一次阅读那些文章时,我假设
我正在尝试使用 PHPMailer 在我的网站上创建联系表单。我在设置时遇到一些问题。我正在尝试使用 G-mail 作为我的 smtp 主机。我想知道是否有人可以帮助解决这个问题? 这是我的邮件代码:
我有一个大约 150 封电子邮件的文件夹,全部保存为 HTML 文件(Firefox 扩展),并且我需要捕获始终在“已发送”行中找到的年份;如下图所示。 我尝试使用 RegEx 但失败了;它根本不会打
我正在 Swift 中基于 NSObject 开发自定义类。它是一个状态菜单图标/菜单助手。当我收到在自定义类中单击图标的事件时,我想以 NSButton 允许创建 IBAction 来响应用户单击按
我尝试使用 MPI 对矩阵求和来执行此操作,我不知道为什么,但我无法使用 MPI_Send 发送任何类型的数据,但无论我在尝试什么我会收到一条错误消息吗: Sending 3 rows to task
我正在开发一个简单的收件箱/下午系统,我不明白为什么,但我可以显示已发送消息的显示,我可以显示已发送项目的列表,从收件箱查看下午消息,但不能确定我做错了什么,任何提示表示赞赏.. 这是我的代码:
我正在尝试在内容脚本和扩展程序之间传递消息 这是我在内容脚本中的内容 chrome.runtime.sendMessage({type: "getUrls"}, function(response)
我正在尝试将一段分成几个词。我手边有可爱的 nltk.tokenize.word_tokenize(sent),但是 help(word_tokenize) 说,“这个分词器被设计为一次处理一个句子。
我在从设备读取 SMS 消息时遇到问题。获取 URI content://sms/inbox 的内容提供者时,一切都很好。我可以阅读 person 列以在 people 表中找到外键并最终到达联系人及
我知道这个网站上有类似的问题,我已经尝试了一些建议的解决方案,其中一些对之前提出这个问题的人有效。但是,我仍然收到发送两次而不是一次的相同数据。 这是代码: final ProgressDialog
当做programmatic file upload时使用jQuery-File-Upload plugin启用分块后,我无法发送多个文件。 我调用电话的方式如下: fileUploadWidget.
我是一名优秀的程序员,十分优秀!