eztalk
asked on
NSThread - NSURLConnection
i started implement call of getting content from URL, but I get exception
I call
[NSThread detachNewThreadSelector:@s elector(lo adURL:) toTarget:self withObject:nil];
and then
- (void)loadURL:(id)param {
NSAutoreleasePool* poolL = [[NSAutoreleasePool alloc] init];
NSData *data;
NSURL *url = [NSURL URLWithString: @"http://www.ya.ru" ];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: url
cachePolicy: NSURLRequestReloadIgnoring CacheData
timeoutInterval: 10];
NSURLResponse *response;
NSError *error;
data = [NSURLConnection
sendSynchronousRequest: request
returningResponse: &response
error: &error];
NSString *output = [NSString stringWithCString:[data bytes] length:[data length]];
NSLog(@"Page = %@", output);
[data release];
[url release];
[request release];
[response release];
[error release];
[poolL release];
}
and get
Program received signal: EXC_BAD_ACCESS.
If I didn't use poolL
I get many comment on console about leak:
*** _NSAutoreleaseNoPool(): Object 0x457ad0 of class UIAlertView autoreleased with no pool in place - just leaking
I call
[NSThread detachNewThreadSelector:@s
and then
- (void)loadURL:(id)param {
NSAutoreleasePool* poolL = [[NSAutoreleasePool alloc] init];
NSData *data;
NSURL *url = [NSURL URLWithString: @"http://www.ya.ru" ];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: url
cachePolicy: NSURLRequestReloadIgnoring
timeoutInterval: 10];
NSURLResponse *response;
NSError *error;
data = [NSURLConnection
sendSynchronousRequest: request
returningResponse: &response
error: &error];
NSString *output = [NSString stringWithCString:[data bytes] length:[data length]];
NSLog(@"Page = %@", output);
[data release];
[url release];
[request release];
[response release];
[error release];
[poolL release];
}
and get
Program received signal: EXC_BAD_ACCESS.
If I didn't use poolL
I get many comment on console about leak:
*** _NSAutoreleaseNoPool(): Object 0x457ad0 of class UIAlertView autoreleased with no pool in place - just leaking
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
http://www.cocoadev.com/index.pl?MemLeaksWithMultiThreadNSURLConnection