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?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- back button text does not change
- iOS (objective-c) compression_decode_buffer() retu
- how to find the index position of the ARRAY Where
相关文章
- 现在使用swift开发ios应用好还是swift?
- TCC __TCCAccessRequest_block_invoke
- xcode 4 garbage collection removed?
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- How can I add media attachments to my push notific
- Popover segue to static cell UITableView causes co
- “Storyboard.storyboard” could not be opened
A more elegant way to show a leak is to have a class having strong pointer to itself
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.