Search code examples
iosiphoneobjective-cmemory-leaksmbprogresshud

Memory leak when using MBProgressHUD


I am using the MBProgressHUB as the loading indicter. I noticed via Instruments, There's considerable memory leak when using MBProgressHUB ( Around 3MB each time its initiate. And issue is, memory DOES NOT clear when the view unload ).

Project is ARC enabled

This is how I am initiate MBProgressHUB in ViewDidLoad (HUD is retained property too)

HUD = [[MBProgressHUD alloc] initWithView:[(AppDelegate *)[[UIApplication sharedApplication]     delegate] window]];
[[(AppDelegate *)[[UIApplication sharedApplication] delegate] window] addSubview:HUD];
HUD.delegate = self;

Also in the ViewDidUnload I am setting HUD = nil;

Any ideas???


Solution

  • I manage to solve the issue by Initializing MBProgressHUB only a single time in the AppDelegate. And use only a reference to that in other places