Reputation: 246
Hi all I get memory leaks on the leaks instrument whenever I trigger this method. Do you think anything is wrong with this??
static NSString* readStringOrDie(InputData *input, size_t length, NSStringEncoding encoding)
{
NSString *str = [[NSString alloc] initWithBytes: readOrDie(input,length)
length: length
encoding: encoding]; // HERE THE LEAK COMES !!
if (!str)
[NSException raise: BERParserException format: @"Unparseable string"];
return [str autorelease];
}
Upvotes: 0
Views: 115
Reputation: 100652
That code is fine. Most likely the actor that receives str retains it and subsequently fails to release it. Instruments knows where memory that has leaked was allocated but doesn't know where it should have been released, so it can provide some slightly unhelpful clues.
Upvotes: 3