低内存警告总是导致iPad崩溃(第1代) [英] Low Memory Warning always causing crash on iPad (1st generation)

查看:531
本文介绍了低内存警告总是导致iPad崩溃(第1代)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的第一代iPad(iOS 5.0.1)测试版之一抱怨不断崩溃。从描述给我们的方式来看,我们确信崩溃发生在设备收到低内存警告时。

One of my beta testers with an 1st generation iPad (iOS 5.0.1) is complaining of constant crashing. From the way it is described to us we are sure that the crash happens as the device receives a low memory warning.

为了证明这一点,我们给了测试人员一个版本的构建没有足够的内存推动低内存警告,它工作正常。但这不是一个解决方案。

To prove this we gave the tester a version of the build that did not push the memory enough for a low memory warning and it works fine. But this is not a fix.

我们有一个很好的20代第一代iPad作为beta测试者,但没有一个有同样的问题。

We have a good 20 1st generation iPads as beta testers and none of them are having this same issue.

是否有可能在设备上设置可能导致内存不足警告崩溃的内容?

Is it possible that something could be set on the device that might cause it to crash on low memory warning?

可以iOS 5.0.1安装不正确?

Could iOS 5.0.1 have been installed incorrectly?

有没有人知道为什么这个设备特别是在低内存警告而不是其他设备上崩溃?

Has anyone got any idea why this device in particular is crashing on low memory warnings and no other?

任何帮助都会非常感激,
- Rich

Any help would be much appreciated, - Rich

推荐答案

可以肯定的是,你应该试试从设备获取崩溃日志。测试人员必须将设备与iTunes同步,然后导航到iTunes复制任何崩溃报告的文件夹。这取决于您使用的平台。

To be sure, you should try to get the crash log from the device. The tester has to sync the device with iTunes, and then navigate to the folder where iTunes copied any crash reports. This depends on what platform you are using.

Mac OS X: ~/Library/Logs/CrashReporter/MobileDevice/<DEVICE_NAME>
Windows XP: C:\Documents and Settings\<USERNAME>\Application Data\Apple Computer\Logs\CrashReporter\MobileDevice\<DEVICE_NAME>
Windows Vista or 7: C:\Users\<USERNAME>\AppData\Roaming\Apple Computer\Logs\CrashReporter\MobileDevice\<DEVICE_NAME>

< USERNAME> 是用户的登录信息计算机的名称。 < DEVICE_NAME> 是iPod touch或iPhone的名称,例如我的iPhone。

<USERNAME> is the user's login name for the computer. <DEVICE_NAME> is the name of the iPod touch or iPhone, for example, "My iPhone".

有一些方法可以自动收集崩溃报告,我在这里发布了关于可能性的概述作为另一个答案的一部分:将自定义数据包含在iOS故障转储中

There are ways to collect the crash reports automatically, I posted an overview on the possibilities as part of another answer here: Including custom data into iOS crash dumps

此外,您可以在iOS模拟器中进行测试时自动执行内存警告。子类 UIViewController 并在视图控制器出现时自动触发内存警告。

In addition you can automate memory warnings when testing in the iOS simulator. Subclass UIViewController and automatically trigger memory warnings whenever the view controller appears.

以下是一些关于如何做的示例代码那:

Here is some example code on how to do that:

#import "BaseViewController.h"

@interface BaseViewController (Private)
- (void)simulateMemoryWarning;
@end

@implementation BaseViewController

- (void) viewDidAppear:(BOOL)animated {
  [super viewDidAppear:animated];

#if TARGET_IPHONE_SIMULATOR
#if defined (CONFIGURATION_Debug)
  // If we are running in the simulator and it's the DEBUG target
  // then simulate a memory warning. Note that the DEBUG flag isn't
  // defined by default. To define it add this Preprocessor Macro for
  // the Debug target: DEBUG=1
  [self simulateMemoryWarning];
#endif
#endif
}

- (void)simulateMemoryWarning {
#if TARGET_IPHONE_SIMULATOR
#if defined (CONFIGURATION_Debug)
  SEL memoryWarningSel = @selector(_performMemoryWarning);
  if ([[UIApplication sharedApplication] respondsToSelector:memoryWarningSel]) {
    [[UIApplication sharedApplication] performSelector:memoryWarningSel];
  } else {
    NSLog(@"%@",@"Whoops UIApplication no loger responds to -_performMemoryWarning");
  }
(CFStringRef)@"UISimulatedMemoryWarningNotification", NULL, NULL, true);
#endif
#endif
}

@end

现在在子类化自己的视图控制器而不是从UIViewController子类化时使用它。此代码最初发布在 https://gist.github.com/956403 并已调整为可以使用Xcode 4.2.1通过添加此处的解决方案 https://stackoverflow.com/a/2785175/474794

Now use this when subclassing your own view controller instead of subclassing from UIViewController. This code was originally posted here https://gist.github.com/956403 and adjusted to work with Xcode 4.2.1 by adding the solution from here https://stackoverflow.com/a/2785175/474794

这篇关于低内存警告总是导致iPad崩溃(第1代)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆