I am working through the chapter on memory management and have a burning question.
According to the authors, with ARC off we need to release the following objects:
— newEntry objects
— weekComponents objects
— array object
Why don’t we need to release the iWeeksFromNow objects and the cal object?
Interestingly, adding [cal release] just before the end of the programme does not crash it, which I understand as proof that cal was indeed lingering in the memory (but because of its small and predictable size cannot cause an application crash, therefore may be safely left in memory until the program exits).
However, adding the [iWeeksFromNow release] instruction in the loop DOES crash the programme (bad access exception). Which means that iWeeksFromNow is “automatically” deallocated and indeed should not be manually released.
So—how come? What’s going on
UPDATE: Actually, releasing the cal object also leads to an exception throw.