I would like to demonstrate memory leak and zombie object in Xcode Instruments on a class. I’ve found it pretty hard to trigger on purpose, especially with ARC turned on. Do you know how could I create them?
I would like to demonstrate memory leak and zombie object in Xcode Instruments on
Share
For A leak:
Create two classes, A and B. A should have an @property that strongly references an instance of B. B should have an @property that strongly references an instance of A.
That’ll create a leak.
For a Zombie
Create a @property that is of type
assign(or a variable of type__unsafe_unretained. Then:That should create a zombie situation; a dangling pointer, more specifically.