Note that there are some explanatory texts on larger screens.

plurals
  1. POWhere is the leak?
    text
    copied!<p>I don't get it! Instruments is showing me a leak in this method</p> <pre><code>-(void)loadData { if (locationData != nil) { [locationData release]; } self.locationData = [[NSMutableArray alloc] init]; NSData *recievedData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://htmlwin001.******.net/blutalkasp/locations2.asp?uid=%@&amp;von=%d&amp;bis=%d", [[UIDevice currentDevice] uniqueIdentifier], von, bis]]]; NSString *recievedString = [[NSString alloc] initWithData:recievedData encoding:NSUTF8StringEncoding]; SBJsonParser *json = [[SBJsonParser alloc] init]; NSMutableDictionary *jsonData = [json objectWithString : recievedString]; NSString *tmpLocationData; for (NSDictionary *location in [jsonData objectForKey:@"items"]) { Location *newLocation = [[Location alloc] init]; tmpLocationData = [[NSString alloc]initWithFormat:@"%@", [location objectForKey:@"id"]]; [newLocation setLocationID:tmpLocationData]; [tmpLocationData release]; tmpLocationData = [[NSString alloc]initWithFormat:@"%@", [[location objectForKey:@"locationname"] gtm_stringByUnescapingFromHTML]]; [newLocation setLocationName:tmpLocationData]; [tmpLocationData release]; tmpLocationData = [[NSString alloc]initWithFormat:@"%@",[location objectForKey:@"locationdistance"]]; [newLocation setLocationDistance:tmpLocationData]; [tmpLocationData release]; tmpLocationData = [[NSString alloc]initWithFormat:@"%@", [[location objectForKey:@"locationaddress"] gtm_stringByUnescapingFromHTML]]; [newLocation setLocationAdress:tmpLocationData]; [tmpLocationData release]; tmpLocationData = [[NSString alloc]initWithFormat:@"%@", [[location objectForKey:@"locationdescription"] gtm_stringByUnescapingFromHTML]]; [newLocation setLocationDescription:tmpLocationData]; [tmpLocationData release]; NSNumber *tmpLocationLat = [[NSNumber alloc] initWithInteger:[[location objectForKey:@"locationlatitude"]integerValue]]; [newLocation setLocationPositionLat:tmpLocationLat]; [tmpLocationLat release]; NSNumber *tmpLocationLng = [[NSNumber alloc] initWithInteger:[[location objectForKey:@"locationlongitude"]integerValue]]; [newLocation setLocationPositionLng:tmpLocationLng]; [tmpLocationLng release]; NSString *URL; URL = [location objectForKey:@"locationimage1"]; URL = [URL stringByReplacingOccurrencesOfString:@"[SLASH]" withString:@"/"]; NSString *tmpUrl1 = [[NSString alloc]initWithFormat:@"http://htmlwin001.******.net/blutalkasp/locationimages/data/%@", URL]; [newLocation setLocationImageURL1:tmpUrl1]; [tmpUrl1 release]; URL = [location objectForKey:@"locationimage2"]; URL = [URL stringByReplacingOccurrencesOfString:@"[SLASH]" withString:@"/"]; NSString *tmpUrl2 = [[NSString alloc]initWithFormat:@"http://htmlwin001.******.net/blutalkasp/locationimages/data/%@", URL]; [newLocation setLocationImageURL2:tmpUrl2]; [tmpUrl2 release]; URL = [location objectForKey:@"locationimage3"]; URL = [URL stringByReplacingOccurrencesOfString:@"[SLASH]" withString:@"/"]; NSString *tmpUrl3 = [[NSString alloc]initWithFormat:@"http://htmlwin001.******.net/blutalkasp/locationimages/data/%@", URL]; [newLocation setLocationImageURL3:tmpUrl3]; //Leak geschlossen [tmpUrl3 release]; [self.locationData addObject:newLocation]; [newLocation release]; } [recievedString release]; [json release]; } </code></pre> <p>Is it possible that <code>[nsdictionaryobject objectForKey:@"xy"];</code> is causing a leak?</p> <p>Because in instrument especially these lines are coloured. As you can see I was releasing everything. I'm quite desperate with that app. I even began to replace all the convenient constructors through alloc/init/release (e.g. <code>initWithFormat</code> instead of <code>stringWithFormat</code>). Especially in loops!</p> <p>But sometimes even instruments crash!</p>
 

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