1

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];

    }
PT Vyas
  • 722
  • 9
  • 31
adamD
  • 125
  • 2
  • solved. LEAKS finds the source of the leak (where the memory is allocated) but not the cause (the last owner who fails to deal with it correctly). So, following the object "NSArray *array" through its life finally led to the problem. – adamD Jun 10 '11 at 23:51
  • Yes. I posted that as an answer to your previous question before you asked this one. :) – Steven Fisher Jul 08 '11 at 08:38
  • just took a little while to process I guess – adamD Jul 22 '11 at 03:58
  • hi @adamD , I am facing the same kind of leaks, can you explain how you resolved it? – Javal Nanda Jul 31 '12 at 11:39

0 Answers0