Note that there are some explanatory texts on larger screens.

plurals
  1. POReceived Memory Warning when MapView is loaded
    primarykey
    data
    text
    <p>I am working on a project in which I have a ViewController with <strong>MapView</strong> in it. </p> <p>Now this page is loaded and dismissed several times.</p> <p>What I first implemented was, I added MapView in xib and and then every time this page loaded then live bites used to increase by 10mb.</p> <p><strong>Solution1</strong></p> <p>Then after doing research for this issue what I found was to use single object for <strong>MKMapView</strong> and define it in <strong>AppDelegate</strong> and use it all the time.</p> <p>I tried this and it decreased the memory usage to some extent but again after sometime the app got crashed due to <strong>Received Memory Warning</strong>.</p> <p>Now if I again launch the app after crash, then it used to crash on the very first time on opening the MapView page, <strong>the live bites at this time were around 11mb only</strong>.</p> <blockquote> <p>This is the code to add mapview in AppDelegate</p> </blockquote> <pre><code> mapView=[[MKMapView alloc]initWithFrame:CGRectMake(0, 0, 300, 450)]; [self.window addSubview:mapView]; mapView.delegate=self; mapView.hidden=YES; </code></pre> <blockquote> <p>This was the code which I used to load Mapview.</p> </blockquote> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; latittude=[[[NSUserDefaults standardUserDefaults]valueForKey:@"LATITUDE"] floatValue]; longitude=[[[NSUserDefaults standardUserDefaults] valueForKey:@"LONGITUDE"] floatValue]; APPDELEGATE.mapView.frame=CGRectMake(0, 140, 320, 290); } -(void)viewDidAppear:(BOOL)animated { APPDELEGATE.mapView.hidden=NO; CLLocationCoordinate2D location; location.latitude = latittude; location.longitude = longitude; Annotation *a; a=[[Annotation alloc]initWithCoordinate:location]; [APPDELEGATE.mapView addAnnotation:a ]; } -(void)viewWillDisappear:(BOOL)animated { APPDELEGATE.mapView.hidden=YES; } </code></pre> <p><strong>Solution2</strong></p> <p>Second solution I found was to change MapView type when view disappears.</p> <p><strong>So I changed its type, changed its delegate to nil and removed from superview on ViewWillDisappear.</strong></p> <p>Even this didn't made any difference.</p> <p>Any idea how can I overcome this problem?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload