Xcode 4+ Tools 4: False Positive Leaks?

Since migrating to Xcode 4, the leak tool has been showing LOT leaks, all from JSONKit and ASIHTTPRequest, after a 2-minute run. I am missing hundreds of arrays / dictionaries / strings (from jk_create_dictionary, jk_parse_array, HTTPMessage :: *, etc.) for a total of a few 100K. Most stack traces do not occur in any of my calls, and the rest are completely innocent. I am pretty sure that this was not the case of pre-Xcode 4. I do not know who the culprit is. Any insight would be perfect.

Update:
JSONKit leaks are probably JSONDecoder caching.
For instance:

static JSONDecoder *decoder = nil; if (!decoder) decoder=[[JSONDecoder alloc] init]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]]; [request setCachePolicy:ASIDoNotWriteToCacheCachePolicy]; [request setCompletionBlock:^{ NSData *response = [request responseData]; NSDictionary *json = [decoder objectWithUTF8String:[response bytes] length:[response length]]; // ... }]; [request setFailedBlock:^{ // ... }]; [request startAsynchronous]; 
+6
objective-c xcode instruments
source share
2 answers

EDIT: Before you read the rest of this answer:

If you see such memory leaks, don't blame Tools or JSONKit ... Both are reliable!

... to blame , 99.9% chance your data leak code that you analyzed with JSONKit !

END_OF_EDIT


Not an answer, rather an addition and an attempt to understand what is happening, since I see leaks with the help of tools.

I use JSONKit this way:

 NSArray *lines = [dataString componentsSeparatedByString:@"\n"]; for (NSString *line in lines) { // I know, strange format isn't? :) NSDictionary *json = [line objectFromJSONStringWithParseOptions:JKParseOptionLooseUnicode]; // use dictionary data... } 

@ssteinberg , is this the type of leak you have ?: JSONKitLeaks

Note that I had this after some testing of a heavy load, 500 requests with huge JSON answers explaining leaks in MB ( using the latest gh version )

Please note that I am completely new using tools and I am not sure how to understand these results. According to Frames, yes, this is similar to Caching ... but I would like to be sure ...

So, I opened Issue on GH , I hope that @johnezang or one of us will inform us about this.

All my apologies if this is just a misunderstanding with the tools that I would prefer :)

+2
source share

According to Apple WWDC 2010 (Advanced Memory Analysis with Instruments) videos, false positive leaks are rare. Sometimes the Leaks tool skips leaks, but it is reliable for the messages it reports. I'm not so good with statics, but did you check to make sure you are not highlighting the decoder without releasing it? If it is not released and falls out of scope, this will constitute a leak, right?

0
source share

All Articles