ios - NSConcreteHashTable rehashAround: 崩溃
问题描述
帮助!!!当我创建 NSAttributedString 时,它有时会崩溃。当它崩溃时,内存使用量很大。可能是内存不足导致了这次崩溃?在创建NSAttributedString的时候,由于内存不足,图片已经释放,从而导致crash?
- (NSMutableAttributedString *)generateIconImageModel:(CREnterIcon *)iconModel fontSize:(CGFloat)fontSize {
if (iconModel.image) {
NSMutableAttributedString *attriString;
NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init];
textAttachment.image = iconModel.image;
textAttachment.bounds = CGRectMake(0, 0, iconModel.showWidth, iconModel.showHeight);
attriString = [[NSMutableAttributedString alloc] initWithAttributedString:[NSAttributedString attributedStringWithAttachment:textAttachment]];
[attriString addAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:fontSize]} range:NSMakeRange(0, attriString.length)];
return attriString;
} else {
return [NSMutableAttributedString new];
}
}
crashReason=SIGSEGV
Thread 44 Crashed:
0 libobjc.A.dylib AutoreleasePoolPage::autoreleaseFullPage(objc_object*, AutoreleasePoolPage*) (in libobjc.A.dylib) + 128
1 libobjc.A.dylib objc_object::rootAutorelease2() (in libobjc.A.dylib) + 108
2 Foundation hashProbe (in Foundation) + 356
3 Foundation -[NSConcreteHashTable rehashAround:] (in Foundation) + 212
4 Foundation hashProbe (in Foundation) + 524
5 Foundation -[NSConcreteHashTable addObject:] (in Foundation) + 48
6 UIFoundation +[NSAttributeDictionary newWithDictionary:] (in UIFoundation) + 1004
7 Foundation -[NSConcreteMutableAttributedString setAttributes:range:] (in Foundation) + 56
8 Foundation -[NSMutableAttributedString addAttributes:range:] (in Foundation) + 224
9 MyAPP -[MSEnterVM generateIconImageModel:fontSize:] (in Myapp) (MSEnterVM.m:293)
10 MyAPP -[MSEnterVM settingEnterType:] (in Myapp) (MSEnterVM.m:0)
11 MyAPP -[MSEnterVM handleEnterMessage:] (in Myapp) (MSEnterVM.m:94)
12 MyAPP __54-[MSDispatchManager onReceiveMessageType:message:]_block_invoke (in Myapp) (MSDispatchManager.m:84)
解决方案
推荐阅读
- android - 使用适配器时刷新android上的活动
- r - 使用 dbinom() 在问卷中以一定百分比出现答案的概率
- bootstrap-4 - MDbootstrap 指定 DataTable 搜索组件的呈现位置
- html - 在带索引的循环中选择单选按钮
- python - 'Sequential' 对象没有属性 'complie'
- regex - 在 Pyspark 中替换多个元素
- cordova - 标签不适用于科尔多瓦应用程序
- vba - VBA - 将列值转换为负值
- sql - 如何为 2 键主键创建标识列
- hybris - SAP HYBRIS - 将 backoffice-config.xml 拆分为多个 xml