我有一个从服务器获取数据的方法。我在循环中多次调用该方法。问题是当我使用仪器检查内存分配时,每个方法调用中的实时内存都增加了。顺便说一句,我正在使用 ARC。
-(NSArray*)callService
{
NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL: serviceURL];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:requestData];
[request setTimeoutInterval:30.0];
NSURLResponse *response = NULL;
NSError *requestError = NULL;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&requestError];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSArray *array = [(NSArray*) [responseString JSONValue] autorelease];
responseString=nil;
return array;
}