{"id":876,"url":"https://github.com/tapwork/HeapInspector-for-iOS","last_synced_at":"2025-07-30T19:33:00.077Z","repository":{"id":23603145,"uuid":"26972032","full_name":"tapwork/HeapInspector-for-iOS","owner":"tapwork","description":"Find memory issues \u0026 leaks in your iOS app without instruments","archived":false,"fork":false,"pushed_at":"2017-03-08T17:08:16.000Z","size":34620,"stargazers_count":1859,"open_issues_count":5,"forks_count":139,"subscribers_count":61,"default_branch":"master","last_synced_at":"2024-11-30T20:05:57.028Z","etag":null,"topics":["allocations","arc","backtrace","carthage","cocoapods","heap-snapshot","heapinspector","instruments","ios","leaks","memory-allocation","memory-heap","memory-leaks","memory-management","monitoring","objective-c","performance","performance-analysis","performance-visualization","retain-cycles"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tapwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-21T18:16:13.000Z","updated_at":"2024-11-24T15:15:00.000Z","dependencies_parsed_at":"2022-08-07T11:00:39.568Z","dependency_job_id":null,"html_url":"https://github.com/tapwork/HeapInspector-for-iOS","commit_stats":null,"previous_names":["tapwork/heapinspector"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tapwork%2FHeapInspector-for-iOS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tapwork%2FHeapInspector-for-iOS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tapwork%2FHeapInspector-for-iOS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tapwork%2FHeapInspector-for-iOS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tapwork","download_url":"https://codeload.github.com/tapwork/HeapInspector-for-iOS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228178987,"owners_count":17881119,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["allocations","arc","backtrace","carthage","cocoapods","heap-snapshot","heapinspector","instruments","ios","leaks","memory-allocation","memory-heap","memory-leaks","memory-management","monitoring","objective-c","performance","performance-analysis","performance-visualization","retain-cycles"],"created_at":"2024-01-05T20:15:33.595Z","updated_at":"2024-12-04T19:32:16.511Z","avatar_url":"https://github.com/tapwork.png","language":"Objective-C","readme":"# HeapInspector\n## Find memory issues \u0026 leaks in your iOS app\n[![Build Status](https://api.travis-ci.org/tapwork/HeapInspector-for-iOS.svg?style=flat)](https://travis-ci.org/tapwork/HeapInspector-for-iOS)\n[![CocoaPods Version](http://img.shields.io/cocoapods/v/HeapInspector.svg?style=flat)](https://github.com/tapwork/HeapInspector-for-iOS/blob/master/HeapInspector.podspec)\n[![](http://img.shields.io/cocoapods/l/HeapInspector.svg?style=flat)](https://github.com/tapwork/HeapInspector-for-iOS/blob/master/LICENSE.md)\n[![CocoaPods Platform](http://img.shields.io/cocoapods/p/HeapInspector.svg?style=flat)]()\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Twitter](https://img.shields.io/badge/twitter-@cmenschel-blue.svg?style=flat)](http://twitter.com/cmenschel)\n\nHeapInspector is a debug tool that **monitors the memory heap** with backtrace recording in your iOS app. You can discover memory leaks, no longer used objects, abandoned memory and more issues directly on your device without ever starting Instruments.\n\n#### Memory heap snapshots with backtrace record\nBasically you can inspect the entire heap and see all living objects of your iOS app. \u003cbr\u003e\nTo be more precise you can record the heap for a specific part of the app. For instance when navigating through the menu. Like in Apple's Instruments the snapshot compares the heap before you started recording. For instance you can start the snapshot before you push a new `UIViewController` onto your `UINavigationController` stack and stop after popping the `UIViewController`.\nWith HeapInspector and heap snapshots you can identify:\n* Leaking objects\n* Retain cycles\n* Living objects that are no longer needed\n* static objects like singletons or cached `UIImage`\n* Dirty memory and your objects on the heap\n\nHeapInspector gives you detailed information for the living objects:\n\n* Reference history (backtrace support) See who called retain, strong, release\n* Responder chain for recorded objects\n* Screenshots of the inspected UIView, UIViewController, UIImage\n* Detailed information about the object (Description, frame, properties, iVars, methods)\n\n# In Action\n\n![HeapInspector](README_Xtras/screencast.gif)\n\n\n# Why\nSince ARC has been introduced we don't need to manage the `retain` \u0026 `release` anymore. ARC is very powerful and makes Objective-C more stable. ARC decreased the number of crashes and improves the memory footprint.\u003cbr\u003e ARC is technically doing a powerful job. It knows when to `retain`, `autorelease` and `release`.\n\u003cbr\u003eBut ARC doesn't think about the overall architecture how to design for low memory usage. You should be aware that you can still do a lot of things wrong with your memory (even with ARC). You can still get memory pressures or peaks with ARC.\n* You can still create Retain Cycles\n* The `strong` property lifetime qualifier can be misused (i.e. holding an object twice and longer than needed.)\n* Memory peaks through loops (if you're not using a proper `@autoreleasepool`)\n* Wrong caching with `static`\n\nAnd that's why we introduced HeapInspector to find those issues.\n\n# Installation\n### CocoaPods\nHeapInspector runs with Objective-C and Swift via CocoaPods\nJust add the HeapInspector to your `Podfile`.\n```\npod \"HeapInspector\"\n```\nand run `pod install` afterwards.\n\n### Carthage \nYou can use [Carthage](https://github.com/Carthage/Carthage). \nSpecify in Cartfile:\n\n```ruby\ngithub \"tapwork/HeapInspector-for-iOS\"\n```\n\n### Manual \nDownload the repository into your project via git or just as zip.\nDrag it the `HeapInspector` folder into your Xcode project. See following image.\n\nDisable ARC for `NSObject+HeapInspector.m` by adding `-fno-objc-arc` to Xcode's Build Phases -\u003e Compile Source. See example images here: [Drag](README_Xtras/drag.png) and [disable ARC](README_Xtras/no_arc.png)\n\n# How to use it\n\nMake sure to import the header file\u003cbr /\u003e\n**Objective-C**\n```objc\n@import HeapInspector;\n```\n**Swift**\n```swift\nimport HeapInspector\n```\n\n### Start\nJust run the following to start HeapInspector in a separated debug window. The window can be moved on your screen in order to reach all your UI elements. The left circle button starts / stops the memory heap snapshot. See demo above.\u003cbr /\u003e\n**Objective-C**\n```objc\n[HINSPDebug start];\n```\n**Swift**\n```swift\nHINSPDebug.start()\n```\n\nWe recommend to use a specific class prefixes, Swift modules or even a real classes like `UIImageView`.\nOr just run `start` to record all NSObject subclasses.\u003cbr /\u003e\n**Objective-C**\n```objc\n[HINSPDebug addClassPrefixesToRecord:@[@\"RM\", @\"UITableView\"];\n```\n**Swift**\nYou can register modules for the heap snapshot and recordings.\n```swift\nHINSPDebug.addSwiftModulesToRecord([\"MyModule\", \"AnotherFrameworkModule\"])\n```\n### Stop\nStopping and removing the inspector's window goes with\u003cbr /\u003e\n**Objective-C**\n```objc\n[HINSPDebug stop];\n```\n**Swift**\n```swift\nHINSPDebug.stop()\n```\nJust call the start/stop methods at app launch or via your custom button.\n\n### Backtrace record\nHeapInspector can also record the backtrace for each object that received an alloc, retain, release or dealloc.\nUse this only with very specific recorded classes or in smaller apps.\nStart the backtrace with\u003cbr /\u003e\n**Objective-C**\n```objc\n[HINSPDebug recordBacktraces:YES]; \n```\n**Swift**\n```swift\nHINSPDebug.recordBacktraces(true)\n```\n\n# Example project\nHeapInspector comes with an example project. There you will see a lot of mistakes made with the memory design.  \n* `strong` delegate properties\n* `NSTimer` that is not being invalidated properly\n*  Holding objects longer than needed. `strong` property for the `UIViewController` that is pushed onto the `UINavigationController` stack\n\n# References, Inspirations \u0026 Thanks\n* [FLEX](https://github.com/flipboard/flex) by [Ryan Olson](https://twitter.com/ryanolsonk)\n* [Mike Ash](https://www.mikeash.com/pyblog/friday-qa-2011-09-30-automatic-reference-counting.html) Friday Q\u0026A Automatic Reference Counting\n* [Clang](http://clang.llvm.org/docs/AutomaticReferenceCounting.html) Objective-C Automatic Reference Counting (ARC)\n\n# Author\n* [Christian Menschel](http://github.com/tapwork) ([@cmenschel](https://twitter.com/cmenschel))  ([@xing](https://twitter.com/xingdevs))\n\n# License\n[MIT](LICENSE.md)\n","funding_links":[],"categories":["Code Quality","awesome-ios ##","Objective-C  Stars 1000以内排名整理","Objective-C"],"sub_categories":["Other free courses","Getting Started"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftapwork%2FHeapInspector-for-iOS","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftapwork%2FHeapInspector-for-iOS","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftapwork%2FHeapInspector-for-iOS/lists"}