我正在我的 iOS 应用程序上运行内存分配分析器,我检测到当前创建了 8MB 内存并且仍然存在于我的应用程序中。显然有什么不对劲。所以我深入研究,这是我可以向您展示的图像:
知道为什么这是原因吗?这似乎是一个自动释放的对象,所以它不应该被释放而不是生活在内存中吗?
以下是我调用函数 parseTagsInComment 的方式:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *commentsText = [NSString stringWithFormat:@"%@ %@", self.imageComment_.username_, self.imageComment_.text_];
NSRange range;
range.location = 0;
range.length = commentsText.length;
NSMutableAttributedString* attrStr = [[NSMutableAttributedString alloc] initWithString:commentsText];
[attrStr setFont:[UIFont fontWithName:@"HelveticaNeue" size:14] range:range];
self.commentAttributedString_ = attrStr;
[attrStr release];
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf.commentsText_ setAlpha:0.0];
[weakSelf.commentsPostedTime_ setAlpha:0.0];
[weakSelf.commentsText_ setFrameWidth:weakSelf.contentView.frameWidth - weakSelf.profilePicture_.frameWidth - kCommentsPadding];
[weakSelf.commentsText_ setFrameHeight:weakSelf.imageComment_.commentHeight_ - 30];
[weakSelf.commentsText_ setAttributedString:weakSelf.commentAttributedString_];
[weakSelf.commentsText_ setLinkColor:weakSelf.textColor_];
NSString *timePosted = [NSString timestampToString:weakSelf.imageComment_.createdTime_];
CGSize commentsTimeSize = [timePosted sizeWithFont:weakSelf.commentsPostedTime_.font constrainedToSize:CGSizeMake(weakSelf.commentsText_.frameWidth, 50)];
[weakSelf.commentsPostedTime_ setText:timePosted];
[UIView animateWithDuration:0.3 animations:^{
[weakSelf.commentsText_ setAlpha:1.0];
[weakSelf.commentsPostedTime_ setAlpha:1.0];
} completion:^(BOOL finished){
[weakSelf parseTagsInComment];
}];
});
[pool release];
});