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


Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

Subscribe to new posts:

You'll get an email whenever a I publish a new post to my blog and nothing more. -- Corbin

As an Amazon Associate I earn from qualifying purchases.

(c) 2008-2024 Corbin Dunn

Privacy Policy

Subscribe to RSS feeds for entries.

62 queries. 0.174 seconds.

Log in