应用程序的实时字节数达到1 GB以上,模拟器显示空白屏幕

时间:2014-01-04 12:46:40

标签: ios memory malloc instruments

我在一个大项目中工作。直到最后一小时都没有问题。突然,我的应用程序的实时字节不断增加,触及超过1 GB,我甚至无法确定问题所在。我搜索并找到this,但它的总字节数不是实时字节。

五分钟后我收到以下错误:

xxxxxx(1456,0x252d1a8) malloc: *** mach_vm_map(size=8388608) failed (error code=3)
*** error: can't allocate region

以下是Instruments的屏幕截图,您可以看到实时字节数达到1 GB。

enter image description here

我已尝试以下步骤

  1. 重置模拟器的内容和设置
  2. 删除Xcode完整的应用程序文件
  3. 删除所有派生文件并完全清理垃圾
  4. 重新安装Xcode
  5. 在这一行中找到更正确的错误

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        [UserNameTxtFld setBackgroundColor:[UIColor colorWithRed:242.0f/255.0f green:245.0f/255.0f blue:245.0f/255.0f alpha:1.0]];
    
        [UserPasswordFld setBackgroundColor:[UIColor colorWithRed:242.0f/255.0f green:242.0f/255.0f blue:242.0f/255.0f alpha:1.0]];
    
        [LoginButton setBackgroundColor:[UIColor colorWithRed:60.0f/255.0f green:179.0f/255.0f blue:113.0f/255.0f alpha:1.0]];
    
        //[ForgotButton setBackgroundColor:[UIColor lightGrayColor]];
    
        API=[[BMAPIClass alloc] init];
        API.delegate    =   self;
    
        UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, UserNameTxtFld.frame.size.height)];
    
        UserNameTxtFld.leftView = paddingView;
    
        UserPasswordFld.leftView =paddingView;
    
        self.appDelegate   =   (BMAppDelegate*)[[UIApplication sharedApplication] delegate];
    
        //Set Splash screen
    
        if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
        {
            CGSize result = [[UIScreen mainScreen] bounds].size;
            if(result.height == 480)
            {
                // iPhone Classic
                NSLog(@"iphone 4");
    
                if(IS_RETINA)
                {
                    NSLog(@"Yes retina Display");
                    splashScreenImage.image =[UIImage imageNamed:@"splash_640x960.jpg"];
                    [visiblePassword setBackgroundImage:[UIImage imageNamed:@"eye_640x960.png"] forState:UIControlStateNormal];
    
                }
                else
                {
                    NSLog(@"Not retina Display");
                    splashScreenImage.image =[UIImage imageNamed:@"splash_320x480.jpg"];
                    [visiblePassword setBackgroundImage:[UIImage imageNamed:@"eye_320x480.png"] forState:UIControlStateNormal];
                }
            }
            if(result.height == 568)
            {
                // iPhone 5
                NSLog(@"iphone 5");
                splashScreenImage.image =[UIImage imageNamed:@"splash_640x1136.jpg"];
                [visiblePassword setBackgroundImage:[UIImage imageNamed:@"eye_640x1136.png"] forState:UIControlStateNormal];
            }
        }
    
    
    }
    

    没有任何效果。任何人都可以说出问题是什么吗?

1 个答案:

答案 0 :(得分:3)

我已在此Link

中看到了您的代码

根据您给定的代码,您多次使用相同的代码。

    UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, UserNameTxtFld.frame.size.height)];

    UserNameTxtFld.leftView = paddingView;

    UserNameTxtFld.leftViewMode =UITextFieldViewModeAlways;

    UserPasswordFld.leftView =paddingView; // this is wrong(can't use it again)
    UserPasswordFld.leftViewMode =UITextFieldViewModeAlways;

您无法再次使用相同的填充视图。您必须再次为UserPasswordFld字段分配它。采取另一个填充视图并使用它然后它将工作。