I’m currently hunting down a memory leak in my app for iPhone. I’m using Instruments to track down the code that is causing the leak (becoming more and more a friend of Instruments!). Now Instruments show two lines: one in dark blue (row 146) and one in a lighter blue (150). From some trial and error I get that they are connected somehow, but not good enough at Objective-C and Memory Management yet to really understand how.
Does anyone know why different colors are used and what could be my problem?
I have tried to release numberForArray but the the app crashes when showing the last line in a picker view.
All ideas appreciated!
(Posting this I also realize that line 139 is redundant! Se there, already an improvement 😉

Ok, lets take a look at the object allocation/ownership behavior of this code…
numberForArrayis assigned the result of-NSString stringWithFormat:, which is an auto-released object. That means that you do not want to release it (as you discovered).That object is then added to the
glucoseLoaderNSMutableArray, which willretainit. You loop 100 times, creating 100 objects and adding them toglucoseLoader. WhenglucoseLoaderis released, at line 154, it will also release all the objects added to it.But wait, there’s more:
firstComponentRangeis created fromglucoseLoaderusing-NSArray initWithArray:. When you do that, all the elements of the source array are added to the destination, which will retain them again.So, when/how do you release
firstComponentRange?