{"id":43,"date":"2005-06-17T08:22:45","date_gmt":"2005-06-17T15:22:45","guid":{"rendered":"http:\/\/www.corbinstreehouse.com\/blog\/?p=43"},"modified":"2018-10-31T10:15:17","modified_gmt":"2018-10-31T17:15:17","slug":"repost-how-to-find-memory-leaks-in-cocoa-apps-with-object-alloc","status":"publish","type":"post","link":"https:\/\/www.corbinstreehouse.com\/blog\/2005\/06\/repost-how-to-find-memory-leaks-in-cocoa-apps-with-object-alloc\/","title":{"rendered":"Repost: How to find memory leaks in Cocoa apps with Object Alloc"},"content":{"rendered":"<p id=\"top\" \/>(The original of this I accidentally killed &#8212; here is a copy).<\/p>\n<td class=\"articleBody\" valign=\"top\">If your Cocoa application leaks memory, here is a way to find those leaks!<\/p>\n<p>1) Open your application in Object Alloc<\/p>\n<p>2) Start the process, and check to have retain events:<\/p>\n<div><img decoding=\"async\" vspace=\"0\" hspace=\"0\" border=\"0\" title=\"Screenshot 1\" alt=\"Screenshot 1\" src=\"\/blog\/focus1.jpg\" \/>\n<\/div>\n<p>\n3) Run to a known state<\/p>\n<p>4) Check &quot;Show since mark&quot;<\/p>\n<div><img decoding=\"async\" vspace=\"0\" hspace=\"0\" border=\"0\" align=\"middle\" title=\"Screenshot 2\" alt=\"Screenshot 2\" src=\"\/blog\/focus2.jpg\" \/>\n<\/div>\n<p>\n5) Click &quot;Auto sort&quot;<\/p>\n<div><img decoding=\"async\" vspace=\"0\" hspace=\"0\" border=\"0\" align=\"none\" title=\"Screenshot 3\" alt=\"Screenshot 3\" src=\"\/blog\/focus3.jpg\" \/>\n<\/div>\n<p>\n6) Click the &quot;Current&quot; column header to sort on that automatically<\/p>\n<div><img decoding=\"async\" vspace=\"0\" hspace=\"0\" border=\"0\" align=\"none\" title=\"Screenshot 4\" alt=\"Screenshot 4\" src=\"\/blog\/focus4.jpg\" \/>\n<\/div>\n<p>\n7) Click the Mark button<\/p>\n<div><img decoding=\"async\" vspace=\"0\" hspace=\"0\" border=\"0\" align=\"none\" title=\"Screenshot 5\" alt=\"Screenshot 5\" src=\"\/blog\/focus5.jpg\" \/>\n<\/div>\n<p>\n8) Do the offending memory leak operation (to warm it up)<\/p>\n<p>9) Click Mark again, and repeat the offending memory leak operation<\/p>\n<p>10) Take a look at the Instance Browser, and find your objects that are leaked<\/p>\n<div><img decoding=\"async\" vspace=\"0\" hspace=\"0\" border=\"0\" align=\"none\" title=\"Screenshot 6\" alt=\"Screenshot 6\" src=\"\/blog\/focus6.jpg\" \/>\n<\/div>\n<p>\n11) Pause the app, and in the right hand browser column will be the<br \/>\nallocation events. Double click on them and you can see the stack of<br \/>\nthe allocation\/retain\/release event, and figure out who isn&#8217;t &quot;playing<br \/>\nnice&quot; by seeing who should have done a release for a corresponding<br \/>\nalloc\/retain\/copy<\/p>\n<div><img decoding=\"async\" vspace=\"0\" hspace=\"0\" border=\"0\" align=\"none\" title=\"Screenshot 7\" alt=\"Screenshot 7\" src=\"\/blog\/focus8.jpg\" \/>\n<\/div>\n<\/td>\n","protected":false},"excerpt":{"rendered":"<p>(The original of this I accidentally killed &#8212; 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&#8230; <a class=\"read-more\" href=\"https:\/\/www.corbinstreehouse.com\/blog\/2005\/06\/repost-how-to-find-memory-leaks-in-cocoa-apps-with-object-alloc\/\">[read more]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[4,6,1],"tags":[63,130,72],"class_list":["post-43","post","type-post","status-publish","format-standard","hentry","category-apple","category-cocoa","category-general","tag-cocoa","tag-objc","tag-programming"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/posts\/43","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/comments?post=43"}],"version-history":[{"count":1,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/posts\/43\/revisions"}],"predecessor-version":[{"id":5331,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/posts\/43\/revisions\/5331"}],"wp:attachment":[{"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/media?parent=43"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/categories?post=43"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/tags?post=43"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}