I made an application that should run constant until I stop it. What it basically does is getting some data from connected another device and send that data to the server periodically using NSURLConnection, and read data from the server periodically and visualize that data as a graph using NSXMLParser.
I ran the instrument to check allocs and leaks. No leak at all. memory monitor shows consistent 5.2 MB. Objectalloc graph is stable, Net bytes of objectallo is arouend 480000 and #net is around 6400.
It crashed about 10 ~ 15 hours later. So I added breakpoint in malloc_error_break.
Now I gets "EXC_BAD_ACCESS" error on Debugger console about 12 hours later.
Any idea?
One suspicious part is SENDING data.
- (void) sendDataToServerWithX:(float)x Y:(float)y{
NSAutoreleasePool *uiUpdatePool = [[NSAutoreleasePool alloc] init];
NSString *urlString = [[NSString alloc] initWithFormat:@"http://www.url.com/save_data.php?user=user1&x=%f&y=%f", x, y];
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:urlString] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) { NSLog(@"sending success"); }
//else { }
NSLog( @"data sent.");
[urlString release];
[theConnection release];
[uiUpdatePool drain];
}
Another suspicious part is READING data:
- (void) readCurrentDataFromServer: (NSTimer *) timer {
NSAutoreleasePool *uiUpdatePool = [[NSAutoreleasePool alloc] init];
XMLParser *parser = [[XMLParser alloc] initXMLParser];
NSURL *url = [[NSURL alloc] initWithString:aString];
NSXMLParser *readXmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
[readXmlParser setDelegate:parser];
[readXmlParser parse];
(...)
[parser release];
[url release];
[readXmlParser release];
[uiUpdatePool drain];
}