title: Application Crash due to Memory issue / MBProgressHUD Indicator
body: <p>I have a  strange issue . 
  I am currently working on a mail app and it used to crash randomly without and error or logs in  my console . I checked my Crash Log it showed me Low Memory warning with jettisoned written next to my App. <img src="https://i.stack.imgur.com/eyWbM.png" alt="Crash Report"></p>
  
  <p>So I suspect it's an memory issue and went back to trace my memory usage of my application. 
  I used allocation instrument to detect the overall usage and my application crashed when it's heap size was just 4.59 MB. <img src="https://i.stack.imgur.com/oftlh.png" alt="Instrument snapshot"></p>
  
  <p>Instruments point towards a function where I am using MBProgressHUD indicator.
  The culprit is this one line :</p>
  
  <pre><code>[appDelegate showHUDActivityIndicatorOnView:self.parentViewController.view whileExecuting:@selector(refreshInBackground) onTarget:self withObject:nil withText:@"Loading"];
  </code></pre>
  
  <p>If I replace this with 
  <code>[self refreshInBackground]</code> everything works fine no issues ..</p>
  
  <p>Here is the code : </p>
  
  <pre><code>    -(void) showHUDActivityIndicatorOnView:(UIView*)view whileExecuting:(SEL)method 
                                     onTarget:(id)target withObject:(id)object withText:(NSString*)label{
      self.HUD = [[MBProgressHUD alloc] initWithView:view] ;
          self.navigationController.navigationItem.hidesBackButton = YES;
          [view addSubview:self.HUD];
      self.HUD.delegate = nil;
      self.HUD.labelText = label;
      [self.HUD showWhileExecuting:method onTarget:target withObject:object animated:YES];    
  }
  </code></pre>
  
  <p><code>self.HUD</code> is a  property which is being retained.</p>
  
  <p>With a slight modification is <code>showWhileExecuting</code> method as follows :</p>
  
  <pre><code>- (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated {
  
      MyAppdelegate *appDelegate = (MyAppdelegate *)[UIApplication sharedApplication].delegate;
      if(!appDelegate.isRequestActive)
      {
      methodForExecution = method;
      targetForExecution = [target retain];
      objectForExecution = [object retain];
  
      // Launch execution in new thread
      taskInProgress = YES;
      [NSThread detachNewThreadSelector:@selector(launchExecution) toTarget:self withObject:nil];
  
      // Show HUD view
      [self show:animated];
      }
      else {
          [self done];
      }
  }
  </code></pre>
  
  <p>currently I have removed this from my app and it works fine now and it does not crashes even with the usage of 20 - 30 MB heap Memory . </p>
  
  <p>I am not looking for an specific answer or solution here . What I am looking for ways to debug / techniques to debug the issue so that I can get to know what caused my app to crash .</p>
  
  <p>Is it memory overflow . If that's the case then how can I use 20-30 MB right now. 
  If it's not an memory issue why does my crash reporter shows jettisoned next to my App name .</p>
  
  <p>the culprit line <code>([appDelegate showHUDActivityIndicatorOnView:self.parentViewController.view whileExecuting:@selector(refreshInBackground) onTarget:self withObject:nil withText:@"Loading"])</code></p>
  
  <p>Every time when I call this function some memory increases , because of some elements being cached . But when memory reached 4.5 MB ...this line cause it to crash </p>
  
  <p>How do I get to the root cause of this issue . How do I figure out why iOS is killing my app the reason for jettisoned written next to my app </p>
  
  <p>Any help or suggestions would be really appreciated . </p>