I’ve created a ipad application and now I’m doing some test with Instruments to found memory leaks and other problem.
I’ve found some leaks, but I can’t understand why they are considered memory leaks… Someone can help me to understand?
NSMutableArray *secondArray = [NSMutableArray arrayWithArray:firstArray];
Why is this a memory leak? Doesn’t it create an array autoreleased?
Well, I still write my answer.
There is no memory leak in this line. You create
secondArrayand it points to the same objects fromfirstArray. arrayWithArray returns autoreleased object, so you haven’t to release it.But I guess that analyzer says than here is a potential situation when you have multiples pointers to one object. And when you release firstArray, then secondArray will refer to undefined memory. It can lead to SIGABRT.