tags:

views:

57

answers:

1

This is what Instruments is pointing to.

students = [[NSMutableArray alloc] initWithArray:[course.students allObjects]];

I'm releasing the array in dealloc. In the rest of my code I'm only calling the array and I'm not alloc'ing it again. I've also tried filling the array via fast enumeration and I get the same problem.

A: 

Just to be sure, add an autorelease to it, like

students = [[[NSMutableArray alloc] initWithArray:[course.students allObjects]] autorelease];

Then see what happens. (maybe assign it to self.students btw, and make that a retained property using @property (nonatomic,retain))

mvds
using autorelease actually made it worse. Instruments runs pretty slow after I get to the bad piece of code and with autorelease it will run slower or even freeze Instruments. I had to reset my computer.
tazboy
Looks like you were correct with having to release it. Somewhere in my code I was releasing a Student *student but I never alloc'ed it. Apparently that was messing with my students array even though I never used that student again. I didn't realize that initWithArray returned an alloc'ed and initialized array which put the retain count to 2. Thank goodness Instruments happen to allow me to see the retain count because it only did that once, as far as I can remember. Thanks again.
tazboy
Is the problem solved? Watch out though with looking at the retain count like that; after an `alloc` and an `initWithArray` the retain count should be just one I think. The 2nd one may be you holding the object - after you function is done though, the autorelease takes off one. (It's just my experience but I learned quickly *not* to interpret retain counts, but rather to look at the code)
mvds
Everything works fine. Thanks for the heads up.
tazboy