iPhone应用程序崩溃,由于低内存,但工作正常在模拟器 [英] iPhone App Crashes due to Low Memory but works fine in simulator

查看:186
本文介绍了iPhone应用程序崩溃,由于低内存,但工作正常在模拟器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,我有一个基于导航的应用程序,共有大约60次查看。

Dear all, I have a navigation-based app with about 60 views.

我使用以下命令运行:
1.构建和分析: bulid是成功的没有抱怨。
2.仪器分配和泄漏:无泄漏。

I have run with the following : 1. Build and analyse : bulid is successful with no complains. 2. Instruments allocation and leaks : no leaks.

然而,应用程序在iPhone或iPad崩溃,但在模拟器中工作正常。
崩溃发生在大约第50个视图。
没有崩溃报告,但我在crashreporter文件夹中看到了LowMemory.log。

However, the app crashed in iPhone or iPad but works fine in simulator. The crash occurs at around 50th view. There is no crash reports but I do see LowMemory.log in the crashreporter folder.

我已将我的iphone和ipad升级到4.2

I have upgraded my iphone and ipad to 4.2

有没有人有想法可能是错误?
我一直在阅读和疑难解答一周。

Does anyone have ideas what could be wrong? I have been reading and troubleshooting for a week.

感谢所有回复。

我的应用程序有一个名为contentViewController的根视图,用户可以从这里导航到4个测验。

My app has a root view called contentViewController and users can navigate to 4 quizzes from here.

这是我用来返回我的根视图的代码。

This is the code I use to return to my root view.

- (void)goHome {
UIAlertView *alert = [[UIAlertView alloc]
                      initWithTitle: @"Warning"
                      message: @"Proceed?"
                      delegate: self
                      cancelButtonTitle:@"Yes"
                      otherButtonTitles:@"No",nil];
[alert show];
[alert release];

}

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
[[self navigationController] setNavigationBarHidden:NO animated:YES];
if (buttonIndex == 0) {
    NSArray * subviews = [self.view subviews];
    [subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.view = nil;
    if (self.contentViewController == nil)
    {
        ContentViewController *aViewController = [[ContentViewController alloc]
                                                  initWithNibName:@"ContentViewController" bundle:[NSBundle mainBundle]];
        self.contentViewController = aViewController;
        [aViewController release];
    }
    [self.navigationController pushViewController:self.contentViewController animated:YES]; 
}

}

推送视图的示例代码:

-(IBAction) buttonArrowClicked:(id)sender {
NSURL *tapSound   = [[NSBundle mainBundle] URLForResource: @"click"
                                            withExtension: @"aif"];

// Store the URL as a CFURLRef instance
self.soundFileURLRef = (CFURLRef) [tapSound retain];

// Create a system sound object representing the sound file.
AudioServicesCreateSystemSoundID (

                                  soundFileURLRef,
                                  &soundFileObject
                                  );
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

if (![[defaults stringForKey:@"sound"] isEqualToString:@"NO"]) {
    AudioServicesPlaySystemSound (soundFileObject);
}       

if (self.exercise2ViewController == nil)
{
    Exercise2ViewController *aViewController = [[Exercise2ViewController alloc]
                                                initWithNibName:@"Exercise2ViewController" bundle:[NSBundle mainBundle]];
    self.exercise2ViewController = aViewController;
    [aViewController release];
}
[self.navigationController pushViewController:self.exercise2ViewController animated:YES];   

}

推荐答案

在模拟器下运行时,通常不会遇到内存问题,所以这些错误不会在此平台上自动遇到。

You will normally not run into memory problems when running under the simulator, so these errors are not automatically encountered on this platform.

可以手动触发低内存事件的功能。如果这实际上是设备上崩溃的原因,那么也可能以这种方式在模拟器中触发相同的错误。

The simulator does however have a feature where you can manually trigger a Low Memory event. If this is actually the cause of the crash on the device, then it might also be possible that you can trigger the same bug in the simulator in this way.

这篇关于iPhone应用程序崩溃,由于低内存,但工作正常在模拟器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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