Tag: memory management

任何iPhone应用程序使用的内存

关于iOS内存管理,有一些我不了解的事情。 我想知道iPhone应用程序在设备上运行时通常需要多少内存(是否有任何修复号如10MB?) 如果一个应用程序包含大量的大图像对内存有什么影响? 它们只在加载时影响内存吗? 当有多个应用运行时,iOS如何管理内存? 请帮我理解这些概念。

NSInvocation和内存问题

所以我来自Java世界,我们对内存pipe理问题非常无知。 大多数情况下,ARC已经救了我的屁股,但是这是让我难住的东西。 基本上我使用NSInvocations的东西,我遇到了一些讨厌的内存问题,我做了下面的代码修改。 由于我做了这些修改,内存崩溃已经消失,但我通常非常害怕我不明白的代码。 我做对了吗? 之前:各种内存问题: NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[target class] instanceMethodSignatureForSelector:selector]]; [invocation setSelector:selector]; [invocation setTarget:target]; [invocation setArgument:&data atIndex:2]; [invocation setArgument:&arg atIndex:3]; [invocation invoke]; NSString *returnValue; [invocation getReturnValue:&returnValue]; 之后:没有内存问题,但我不知道我有这个权利: NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[target class] instanceMethodSignatureForSelector:selector]]; [invocation setSelector:selector]; [invocation setTarget:target]; [invocation setArgument:&data atIndex:2]; [invocation setArgument:&arg atIndex:3]; [invocation invoke]; CFTypeRef result; [invocation getReturnValue:&result]; if (result) […]

如何避免在iOS上延迟块调用的保留周期

我真的很难过这个。 我一直在阅读所有关于如何正确处理块内variables的信息。 注意:我不使用弧。 所以说,我有一个这样的animation: [UIView animateWithDuration:.5 animations:^{ textCard.alpha = 1.f; self.dotView.alpha = 1.f; self.subtitles.alpha = 0; }completion:^(BOOL finished){ [self.playerLayer removeFromSuperlayer]; self.playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.vidPlayer]; self.playerLayer.frame = self.vidView.bounds; [self.vidView.layer insertSublayer:self.playerLayer atIndex:0]; [self.subtitles removeFromSuperview]; self.subtitles = [sub autorelease]; [UIView animateWithDuration:.3 delay:1 options:UIViewAnimationOptionAllowUserInteraction animations:^{ textCard.alpha = 0.f; sub.alpha = 1.f; }completion:^(BOOL finished){ self.queuedVid = NO; if (self.shouldPlay == […]

如何find记忆警告的真正原因,以及如何解决在iOS应用程序

我已经经历了许多相关的内存pipe理,ARC,内存pipe理技术,如autoreleasepool和使用仪器工具来检测哪些代码导致内存警告,但在我的情况下,我无法找出确切的原因。 基本的细节,你必须知道的应用程序: 我们开发了一个iPad应用程序。 在这种情况下,我们必须在某些情况下使用超过2000个图像,所以当我的应用程序启动时,我们不想显示占位符图像(客户端要求)。因此,我们使用SDWebImage ,将图像存储在磁盘上,晚于我们正在从那里加载图片。 有如此多的核心animation,我已经表演过,如“Gennie效果”,显示popup等许多其他核心animation。 我们在我们的项目中使用了ARC,我们发现由于内存警告应用程序随机崩溃。 我们使用仪器 “分配”来find脏记忆。 之前我们对日志进行了分析,并将SDWebImage中的图片存储在DISK中,解决了应用程序频繁崩溃的问题,但是由于内存警告,应用程序仍然崩溃。 当我们深入了解时,我们发现“匿名虚拟机”在iPad上任何屏幕切换时都会保持加载状态而不释放内存。 这里是我们的设备上的应用程序分析截图。 任何人都可以build议提示或编码技术或任何想法,我们可以减less内存负荷和解决内存警告。 任何帮助将不胜感激。 谢谢。