Memory leak that appears to be in touchJSON

核能气质少年 提交于 2019-12-11 08:00:33

问题


Here's a leak problem that I'm having trouble with. Most of this code is just here for context so you can see that the "response" NSData object is not what's leaking.

If I drill down into the touchJSON code, following the stack trace as given to me by the LEAKS tool, the leak apparently begins life at the line

 *outStringConstant ....  

But since this is such a commonly used library, I doubt it's the problem.

One note. This doesn't leak the first time it's executed, only every subsequent time. But it leaks a lot, so the response data is probably the actual data that's leaking.

Also, if anyone is familiar with touchJSON and this code, can you explain to me what this outStringConstant variable is and what it does? It doesn't appear to play any role, other than to be assigned a copy of theString, though if I remove that line the code crashes.

MY CODE is

dataRequestURL = [NSString stringWithFormat:@"http://www....",  ...];

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:dataRequestURL]  cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30];

NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:&ts_response error:&ts_error];

NSArray *array = [[CJSONDeserializer deserializer] deserialize:response error:nil]; <- LEAKS HERE

TOUCHJSON CODE is

   -(BOOL)scanJSONStringConstant:(NSString **)outStringConstant error:(NSError **)outError {

    NSMutableString *theString = [[NSMutableString alloc] init];
if (outStringConstant != NULL) { *outStringConstant = [[theString copy] autorelease]; }

       [theString release];

    }

来源:https://stackoverflow.com/questions/6301648/memory-leak-that-appears-to-be-in-touchjson

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!