In my application in xml parsing method found character delegate method i use the fallowing code
NSString *Str = [[[NSString alloc] initWithString:foundString] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] ;
if ([weekNames containsObject:elementName]) {
// if (!settings) {
// NSMutableDictionary *dict1=[[NSMutableDictionary alloc]initWithObjectsAndKeys:@"",@"no",@"بسم الله الرحمن الرحيم",@"surah",nil];
// [weekDict insertObject:dict1 atIndex:0];
//}
[array1 addObject:weekDict];
}
if ([elementName isEqualToString:@"DUA"]) {
[weekDict addObject:duaDict];
}
if ([elementName isEqualToString:@"NO"]) {
[duaDict setObject:Str forKey:@"no"];
}
if ([elementName isEqualToString:@"SURAH"]) {
[duaDict setObject:Str forKey:@"surah"];
}
foundString=nil;**
If i use this code in analyze application i got potent6ial memory leak.
If i autorelease the Str it will give too many times releasing .
Why it happens like that. Please any one help me.
Thanks in advance
This:
really should be:
What you are doing now is creating (alloc/init) a new NSString and then immediately leaking it, because you never actually save the pointer. And it turns out you never really needed that NSString to begin with.