{"id":17722,"date":"2017-04-12T15:56:52","date_gmt":"2017-04-12T19:56:52","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=17722"},"modified":"2017-04-12T15:56:52","modified_gmt":"2017-04-12T19:56:52","slug":"automatic-memory-leak-detection-on-ios","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2017\/04\/12\/automatic-memory-leak-detection-on-ios\/","title":{"rendered":"Automatic Memory Leak Detection on iOS"},"content":{"rendered":"<p><a href=\"https:\/\/code.facebook.com\/posts\/583946315094347\/automatic-memory-leak-detection-on-ios\/\">Facebook<\/a>:<\/p>\n<blockquote cite=\"https:\/\/code.facebook.com\/posts\/583946315094347\/automatic-memory-leak-detection-on-ios\/\"><p>Automating this process would allow us to find memory leaks faster without much developer involvement. To address that issue, we have built a suite of tools that allow us to automate the process and fix a number of problems in our own codebase. Today, we are excited to announce that we are releasing these tools: <a href=\"https:\/\/github.com\/facebook\/FBRetainCycleDetector\">FBRetainCycleDetector<\/a>, <a href=\"https:\/\/github.com\/facebook\/FBAllocationTracker\">FBAllocationTracker<\/a>, and <a href=\"https:\/\/github.com\/facebook\/FBMemoryProfiler\">FBMemoryProfiler<\/a>.<\/p><p>[&#8230;]<\/p><p>Fortunately, Objective-C offers a powerful, introspective, runtime library that can give us enough data to dig into the graph.<\/p><p>[&#8230;]<\/p><p>If we know that the reference we are dealing with is a block, we can cast it on a fake structure that imitates a block. After casting the block to a C-struct we know where objects retained by the block are kept. We don&rsquo;t know, unfortunately, if those references are strong or weak.<\/p><p>To do that we are using a blackbox technique. We create an object that pretends to be a block we want to investigate. Because we know the block&rsquo;s interface, we know where to look for references this block holds. In place of those references our fake object will have &ldquo;release detectors.&rdquo; Release detectors are small objects that are observing release messages sent to them.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Facebook: Automating this process would allow us to find memory leaks faster without much developer involvement. To address that issue, we have built a suite of tools that allow us to automate the process and fix a number of problems in our own codebase. Today, we are excited to announce that we are releasing these [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[168,25,31,1380,571,54,760,71],"class_list":["post-17722","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-blocks","tag-facebook","tag-ios","tag-ios-10","tag-memory-management","tag-objective-c","tag-objective-c-runtime","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17722","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=17722"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17722\/revisions"}],"predecessor-version":[{"id":17723,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17722\/revisions\/17723"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=17722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=17722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=17722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}