Select to view content in your preferred language

iPad Crashing in PresentModalViewController

1252
5
03-26-2013 05:27 AM
FaisalSabri
Emerging Contributor
Hi ,

i'm building an application that is loading the map in different view from the main view ..

in the first view i'm getting the service url and checking for user name and password .. once the user click "login" i will load
the map using the following :


MapViewController *MapView = [self.storyboard instantiateViewControllerWithIdentifier:@"MapView"];
[self presentModalViewController:MapView animated:YES];
[MapView release];



in the MapViewController i'm loading the Following Graphics Layers in "viewdidload" :

- 2 AGSDynamicMapServiceLayer ..
- 2 AGSFeatureLayer ..
- 5 AGSGraphicsLayer ( i'm adding the Graphicslayer to the map only when i need it , otherwise i'm removing it from the map .. i'm only initializing it on the viewdidload ) ..


in the mapviewcontroller there is a button for logut .. if the user click it , it will dismiss the mapview and show the main view again for the user to login like this :

 [self dismissModalViewControllerAnimated:YES];


in the forth time that the user login or logout the application is crashing and i'm getting "Received memory warning" ..

if i remove all the Graphics Layers and Feature Layer and keep only the mapServiceLayer it's working ..


can someone help me please .. ??
0 Kudos
5 Replies
NimeshJarecha
Esri Regular Contributor
If possible, please attach a sample application and exact steps to reproduce issue so I can look into.

Regards,
Nimesh
0 Kudos
FaisalSabri
Emerging Contributor
If possible, please attach a sample application and exact steps to reproduce issue so I can look into.

Regards,
Nimesh


Dear Nimesh ,

Please find attached the sample application ,

what i'm doing exactly is the following :

- the user is clicking on login button ..

- it will show the mapview with some of graphic layers ..

- there is a logout button .. if the user click it the application will crash .. 


and that's it ..

Thank you in advance ..
0 Kudos
NimeshJarecha
Esri Regular Contributor
It's crashing because you are over releasing. Just comment out [MapView release]; as below and it should work. Also, you should convert your project to ARC so you won't have to worry about memory management.

- (IBAction)btn_login_Clicked:(id)sender
{
    MapViewController *MapView = [self.storyboard instantiateViewControllerWithIdentifier:@"MapView"];
   
    [self presentViewController:MapView animated:YES completion:^
        {
            NSLog(@"Login Finished");
        }
     ];
   
    //[MapView release];
}

Regards,
Nimesh
0 Kudos
DanaMaher
Regular Contributor
.

- there is a logout button .. if the user click it the application will crash .. 

and that's it ..

Thank you in advance ..


Faisal,

Is there a reason you are not using Automatic Reference Counting (ARC)? I could not pinpoint your exact problem, but it has all the signs of a memory management issue. Also, you are not doing a bunch of memory management within your MapViewController class that should be done in a non-ARC project. I actually did not realize that you are not using ARC until I noticed that you have a - (void)dealloc in place.

The crash disappeared after I converted your test project to ARC, which you can do within XCode by selecting Edit->Refactor->Convert to Objective-C ARC. I attached the converted project. If you don't want to use ARC, you need to explicitly release all objects you create when you no longer need them. In your original, non-ARC code, a number of members of your MapViewController class are never being released.
0 Kudos
FaisalSabri
Emerging Contributor
It's crashing because you are over releasing. Just comment out [MapView release]; as below and it should work. Also, you should convert your project to ARC so you won't have to worry about memory management.

- (IBAction)btn_login_Clicked:(id)sender
{
    MapViewController *MapView = [self.storyboard instantiateViewControllerWithIdentifier:@"MapView"];
   
    [self presentViewController:MapView animated:YES completion:^
        {
            NSLog(@"Login Finished");
        }
     ];
   
    //[MapView release];
}

Regards,
Nimesh


Nimesh ,

i did remove it before .. but it give the same issue ..


Dana ,

i did convert my project to ARC before , and i was getting the same issue .. 

please note that the sample i have attached is only the concept that i'm doing in my original project ..


i will try to search more about the issue .. i hope it's not From the SDK .. but as i said before the application works perfect if i removed any Graphiclayer or FeatureLayer from the project ..

Thank you all for your help ..
0 Kudos