Im really having a problem with determining locations of my leaks, my client detected it via TARGETS > RUN STATIC ANALYZER
and set to YES. And then in Product
click Analyze
He was able to see something like this:
But in mine I wasn't able to output the same as above. Tried searching in the internet, but there weren't working. Am I missing something. Any help would be appreciated.
self.responseData = [[NSMutableData alloc] initWithCapacity:[data length]];
This creates and initializes an object. Therefore, that function owns that object. If you are using your properties properly, it will either be retained when assigned (in that statement), and released when that field is reassigned (declared retain
), or copied and the copy will be released appropriately ( copy
). Either of these leaves the object with a retain count of 1 and no pointers to it, the definition of a leak. You need to release
or autorelease
that object somewhere in that function.
self.responseData = [[[NSMutableData alloc] initWithCapacity:[data length]] autorelease];
or
NSMutableData *newData = [[NSMutableData alloc] initWithCapacity:[data length]];
self.responseData = newData;
[newData release];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.