Ok, let's take a look at the behavior of the object / owner of this code ...
numberForArray assigned the result -NSString stringWithFormat: which is an automatically issued object. This means that you do not want to free him (as you discovered).
This object is then added to the glucoseLoader NSMutableArray, which will be retain . You loop 100 times, creating 100 objects and adding them to glucoseLoader . When the glucoseLoader freed, on line 154 it will also free all objects added to it.
But wait, there's more: firstComponentRange is created from glucoseLoader using -NSArray initWithArray: When you do this, all elements of the source array will be added to the destination, which will save them again.
So when / how do you release firstComponentRange ?
source share