Memory Managment and NSMutableArray

arrayWithCapacity: doesn’t say alloc, copy or new, therefore, it is autoreleased. You leave the scope of this method and that object is destroyed.

[[NSMutableArray alloc] init…] is actually two messages: one of which, contains alloc. Therefore, the object is not autoreleased and wil exist until you release it.

The reason you see the error message you do is because after the array was destroyed, an NSString somewhere was instantiated and took up the same spot in memory that the array used to occupy. Your variable, which points to a spot in memory and doesn’t actually represent an object, is now pointing at that string.