코드에 대한 자세한 정보를 제공했습니다. checkstatusthread()
은 5 초마다 호출됩니다. 아래에 사용 된 ipItemsArray
객체는 서버에서 오는 XML을 저장합니다.NSMutableArray를 사용하는 또 다른 메모리 누수
// XMLAppDelegate.h
@interface XMLAppDelegate : NSObject <UIApplicationDelegate> {
NSMutableString *hostStr2;
NSData *dataURL2;
NSString *playlistdata;
}
@property (nonatomic, retain) NSMutableString *hostStr2;
@property (nonatomic, retain) NSData *dataURL2;
@property (nonatomic, retain) NSString *playlistdata;
@end
// XMLAppDelegate.m
-(void)checkstatusthread
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
hostStr2 = [[NSMutableString alloc] initWithFormat:@"http://%@/getplaylist.php?ip=%@",yourip,restip];
dataURL2 = [NSData dataWithContentsOfURL: [ NSURL URLWithString: hostStr2 ]];
playlistdata = [[NSString alloc] initWithData:dataURL2 encoding: NSASCIIStringEncoding];
ipItemsArray = [playlistdata componentsSeparatedByString:@"|^|"];
[hostStr2 release];
[playlistdata release];
status =[ipItemsArray objectAtIndex:0];
[status retain];
if([[ipItemsArray objectAtIndex:0]isEqualToString:@"0001"])
{
serverOutput1 =[ipItemsArray objectAtIndex:1];
[serverOutput1 retain];
nowplaying =[ipItemsArray objectAtIndex:2];
[nowplaying retain];
tracklocation=[ipItemsArray objectAtIndex:3];
[requestlocation retain];
requestlocation=[ipItemsArray objectAtIndex:4];
temp_app =[tracklocation intValue];
}
[serverOutput1 retain];
[nowplaying retain];
[serverOutput1 retain];
[nowplaying retain];
[tracklocation retain];
[requestlocation retain];
// checkstatus() called
[self performSelectorOnMainThread:@selector(checkstatus)
withObject:nil
waitUntilDone:false];
[pool drain];
}
- (void)dealloc {
[dataURL2 release];
[playlistdata release];
[ipItemsArray release];
}
NSArray *ipItemsArray = [playlistdata componentsSeparatedByString:@"|^|"];
나에게 내가 엑스 코드 4.2에서 누수 악기를 실행 메모리 누수를 제공 라인입니다. 이 모든 가능한 일을 시도했지만 뭔가 추가해야한다고 생각합니다. 누군가 나를 도울 수 있습니까?
다음은 누출 된 개체의 스크린 샷입니다. 또한 내 애플 Dealloc 메서드를 호출하지 않는 것으로 나타났습니다. 모든 작업을 완료 한
완료되면 playlistdata 및 hostStr2를 출시 하시겠습니까? –
@ShantiK : 예, 그렇습니다. – maddy2012
상태를 두 번 유지하는 이유는 무엇입니까? –