Graphics Programs Reference
In-Depth Information
Per our understanding of memory management so far, both
BNRItem
s should be des-
troyed along with their instance variables when
items
is set to
nil
. Build and run the
application. Notice that the console does not report that these objects have been destroyed.
This is a retain cycle: the backpack and the calculator have strong references to one anoth-
er, so there is no way to destroy these objects.
Figure 3.8
shows the objects in the applica-
tion that are still taking up memory once
items
has been set to
nil
.
Figure 3.8 A retain cycle!