Domanda

I am working in a big project. There was no problem till last hour. Suddenly my app's live bytes keeps on increasing and it touches above 1 GB and I can't even identify where the problem is. I have searched and found this but its for overall bytes not for live bytes.

I got the following error after five minutes:

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

Here is a screenshot of Instruments and you can see the live bytes reaches 1 GB.

enter image description here

I've tried the following steps

  1. Reset the contents and settings of simulator
  2. Delete Xcode full application files
  3. Delete all derived files and clean trash fully
  4. Re-install Xcode

To be more correct error found in this lines

- (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];
        }
    }


}

Nothing's worked. Can any one could say what the problem is?

È stato utile?

Soluzione

I have seen your code in this Link

As per your given code you have used same code multiple time.

    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;

You can't use same padding view again. You have to alloc it again for UserPasswordFld field. Take another padding view and use it then it will work.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top