I create very simple project with NAvigation controller which root controller is viewController with only one button that point on new mapViewControler that contains mapView.
NavigatioController --> viewController - button --push--> mapViewController with mapView.
This is my code for mapViewController.h:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@interface mapViewController : UIViewController
@property (weak, nonatomic) IBOutlet MKMapView *mapView;
@end
This is my code for mapViewController.m:
#import "mapViewController.h"
@implementation mapViewController
- (void)viewDidLoad
{
[super viewDidLoad];
}
-(void) viewWillDisappear:(BOOL)animated {
//trigered when Back button pressed
if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
[self setMapView:nil];
self.mapView.delegate = nil;
}
[super viewWillDisappear:animated];
}
@end
So when I click button(segue - push), the mapViewController shows up and Live Bytes increase for 40MB - I suppose because of the map images, but when I click back button (navigationControl) the memory decrease only for 39 MB. So 1MB stays somewhere. If I repeat this 100 times this is 100MB. The Leaks tool shows no leaks.
Can somebody explain why this 1MB stays every time I click Back and how to get rid of it?