« Changing the disclosure triangle in an NSOutlineView | Main | Tiger and the keyboard »
June 17, 2005
Finding memory leaks with Object Alloc
So, your app leaks? Here's how to fix it:
1. Open your app in Object Alloc
2. Start the process, and check to have retain events:

3. Run till in a known state
4. Check "Show since mark":

5. Click auto-sort:

6. Click the "Current" column header to sort on that automatically:

7. Click the Mark button:

7. Do the offending memory leak operation (to warm it up)
8. Click Mark again, and repeat the offending memory leak operation.
9. Take a look at the Instance Browser, and find your objects that are leaked:

10. Pause the app, and in the right hand browser column will be the allocation events. Double click on them and you can see the stack of the allocation/retain/release event, and figure out who isn't "playing nice" by seeing who should have done a release for a corresponding alloc/retain/copy:

Have fun!
--corbin
Posted by corbin at June 17, 2005 02:20 PM
Comments
Excellent tip. Welcome to the blogosophere. Always glad to see more Apple developers blogging.
Posted by: Justin Williams at June 17, 2005 07:52 PM