I have provided more information on the code. The checkstatusthread() is called after every 5 seconds. ipItemsArray object used below stores the XML coming from the server.
// 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];
}
The line NSArray *ipItemsArray = [playlistdata componentsSeparatedByString:@"|^|"]; gives me a memory leak when I run the leaks instrument in Xcode 4.2. have tried all possible things on this, but feel like something needs to be added. Can someone please help me out.
Here is the Screenshot of the leaked object. Also i noticed my app doesn’t call Dealloc method.

The object that is leaking is “status”. I infer that it is an iVar. When you do this:
The second time these lines get executed, the previously stored value in status is not released properly, hence a leak. You should ideally be doing this:
This will solve your leak shown in instruments. (Assuming ARC is not being used)