简体   繁体   中英

Crashing due to memory warning even showing 7-8 MB in instruments>>allocations by using ARC

My application is crashing many times due to receive memory warning, even it is showing allocated live bytes as 7-8 MB only as shown in screenshot. 在此处输入图片说明 I'm not getting the issue even after searching all related queries.

i'm using following concepts: 1. shared instance

+ (WSHelper *)sharedInstance
{
    static WSHelper *appInstance = nil;
    if (nil == appInstance)
    {
        appInstance  = [[super allocWithZone:NULL] init];
    }
    return appInstance;
}

2. MBProgressHUD

+ (void)showWaitIndicator:(UIViewController*)parentView
{
    if(![AppGlobals sharedInstance].HUD)
        [AppGlobals sharedInstance].HUD = [[MBProgressHUD alloc] initWithWindow:((AppDelegate *)[UIApplication sharedApplication].delegate).window];
    [((AppDelegate *)[UIApplication sharedApplication].delegate).window addSubview:[AppGlobals sharedInstance].HUD];
    [AppGlobals sharedInstance].HUD.labelText = @"Please Wait...";
    [[AppGlobals sharedInstance].HUD show:TRUE];
}

Please help me out...

Application may crash if an object in your app tries to access another object which is already released from memory. You need to check the scope of all your objects. Try "Analyser" instead to know this.

Nice for having more information on your question :

Replace if (nil == appInstance) with if(appInstance == nil) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM