objective c - Memory leaks because of MRR memory management -
i've got code no-arc project
@interface trssimagedownloader() @property (nonatomic, retain) nsmutabledata *activedownloaddata; @end @implementation trssimagedownloader @synthesize activedownloaddata = _activedownloaddata; -(id)init { self = [super init]; if (self) { _activedownloaddata = [nsmutabledata new]; } return self; } -(void)dealloc { [_activedownloaddata release]; [super dealloc]; } it's working, when i'm testing through "profile"->"leaks", shows memory leaks on activedownloaddata
leaks tells leaked memory allocated. not tell failure correctly release is. either assign _activedownloaddata incorrectly somewhere else, or you're leaking of trssimagedownloader (and so, indirection, leaking _activedownloaddata).
the common cause of problem direct use of ivars. if use accessors everywhere (except init , dealloc), these problems tend go away easily. if use ivars directly inside of object, tend have these kinds of problems. without accessors, need audit every place assign ivar directly , make sure you're releasing old value correctly.
converting arc of course recommended solution if @ possible.
Comments
Post a Comment