Repost: How to find memory leaks in Cocoa apps with Object Alloc

Apple, Cocoa, General

(The original of this I accidentally killed — here is a copy).

If your Cocoa application leaks memory, here is a way to find those leaks!

1) Open your application in Object Alloc

2) Start the process, and check to have retain events:

Screenshot 1

3) Run to a known state

4) Check "Show since mark"

Screenshot 2

5) Click "Auto sort"

Screenshot 3

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

Screenshot 4

7) Click the Mark button

Screenshot 5

8) Do the offending memory leak operation (to warm it up)

9) Click Mark again, and repeat the offending memory leak operation

10) Take a look at the Instance Browser, and find your objects that are leaked

Screenshot 6

11) 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

Screenshot 7
Next in Cocoa
Your most important breakpoint in Cocoa

Leave a Reply

avatar
500
  Subscribe  
Notify of

(c) 2008-2019 Corbin Dunn

Privacy Policy

Subscribe to RSS feeds for entries.

89 queries. 0.921 seconds.

Log in