I am new to Objective C, and I've read several documents both here on Stack Overflow and on Apple's web site about Automatic Reference Counting, but I still can't figure out why "Leaks" is telling me my code is leaking memory. It's probably important to note that all of this code is running on a background thread which is initiated by an NSOperationQueue
.
For example, I have something like this:
NSArray *times = <receives an array of NSStrings>;
NSArray *codes = <receives an array of NSStrings>;
// these two arrays are == in length
NSMutableArray *fingerprint = [NSMutableArray array];
for (int x = 0; x < [times count]; x++) {
long numToAdd = strtol([[codes objectAtIndex:x] cStringUsingEncoding:NSUTF8Encoding], NULL, 16);
[fingerprint addObject:[NSNumber numberWithLong:numToAdd]];
numToAdd = strtol([[times objectAtIndex:x] cStringUsingEncoding:NSUTF8Encoding], NULL, 16);
[fingerprint addObject:[NSNumber numberWithLong:numToAdd]];
}
Leaks claims there is a leak on the line the allocates the array, as well as a leak on the first object add, but not the second. I have no idea why these leaks exist. Any help is appreciated.
If more code is needed, please comment and I'll be happy to provide.