我越来越内存泄露theFileName = [[responseString lastPathComponent]stringByDeletingPathExtension];
iPhone编程+内存泄露
theFileName是一个全局变量。我已经合成它并且
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))
{
// Custom initialization
theFileName = [[NSString alloc] init];
}
return self;
}
- (void)requestFinished:(ASIHTTPRequest *)request{
//internally calls this function
// Use when fetching text data
NSString *responseString = [request responseString];
//NSLog(@"the responsestring for download is:%@",responseString);
theFileName = [[responseString lastPathComponent]stringByDeletingPathExtension];
//NSLog(@"the theFileName for download is:%@",theFileName);
//adds extension .jpg to file name
NSString *[email protected]".jpg";
NSString *addjpg=[theFileName stringByAppendingString:jpg];
//NSLog(@"append %@",addjpg);
}
在dealloc中发布它。
-(void)dealloc
{
[thefileName release];
}
}
你可以发布你的@属性。 – tjg184
有没有可能你没有调用dealloc,你是如何确定这与你的内存泄漏有关的? –
@James:当然,要清楚的是,除了自己的'dealloc'中的'super'之外,您不会自己调用'-dealloc'。说到这一点,你也不会在'super'上调用'dealloc'。 – SK9