Hi I am getting memory leak in Instruments for the following line of code .
NSArray *itemsList=[[NSArray alloc] initWithObjects:@"Love",
@"Hate",@"Happy",@"Sad",
@"Desire",@"Anger",@"Hope",@"Fear",@"Silly",nil];
I am using the below code: arrayList is also released in dealloc block.
NSArray *itemsList=开发者_高级运维[[NSArray alloc] initWithObjects:@"Love",@"Hate",
@"Happy",@"Sad",@"Desire",
@"Anger",@"Hope",@"Fear",@"Silly",nil];
self.arrayList=itemsList;
[itemsList release];
I'm assuming that arrayList
is declared using retain
in the @property
statement. If not, then that is certainly your problem.
If it is, then you have a leak, but not in the code you've posted. It's important to realize that Instruments first shows not necessarily where the leak occurred, but where the leaked memory was allocated. You'll have look through the rest of your uses of arrayList and find where you have a retain that's missing a release.
If you click on the arrow next to the memory address of the object in Instruments, you should be able to see everywhere that your object was retained and released. You'll have look through them and identify which retain is missing a release.
精彩评论