Saturday, March 5, 2011

Memory Management in Objective-C

If you assign a new allocated instance to your iVar with . notation (setter), then be careful about the memory management. Because it may leak if you don't explicitly release the allocated instance. For example below,

self.searchResult = [[[NSMutableArray alloc] init] autorelease];

you need to release RHS, setter will retain the value and if you don't release RHS then you will get memory leak.

No comments:

Post a Comment