i developing an application in which i found memory leak in following method how i remove leak?
- (id)initWithString:(NSString *)str attributes:(NSDictionary *)attributes
{
if ((self = [super init]))
{
_buffer = [str mutableCopy];
_attributes = [NSMutableArray arrayWithObjects:[ZAttributeRun attributeRunWithIndex:0 attributes:attributes], nil];
}
return self;
}
I founding leak near this line “_buffer = [str mutableCopy];”
In allocation stack trace i finding simultaneous memory allocation increasing as a CFString.
Thanks.
I think you will not have a memory leak if you put a line
[_buffer release]indeallocmethod. You have an allocation because for every methods that contains stuff likealloc,retainandcopy… you create a new object instance. And that’s ok in this case.Another thing you have to worry is a memory crash of
_attributesobject. You own an autoreleased object and the next time you try to use it, it may be deallocated already