{"id":21373685,"url":"https://github.com/liangdahong/AMLeaksFinder","last_synced_at":"2025-07-13T08:30:35.437Z","repository":{"id":42055453,"uuid":"263501355","full_name":"liangdahong/AMLeaksFinder","owner":"liangdahong","description":"A small tool for automatically detecting the [controller, view memory leak] in the project.  一款用于自动检测项目中【控制器内存泄漏，View 内存泄漏】的小工具，支持 ObjC，Swift。","archived":false,"fork":false,"pushed_at":"2024-04-20T17:10:17.000Z","size":84333,"stargazers_count":158,"open_issues_count":2,"forks_count":23,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-29T22:48:09.822Z","etag":null,"topics":["controller","ios","leak","leaks","meaksfinder","memory","memory-leak","mleaksfinder","objective-c","runtime"],"latest_commit_sha":null,"homepage":"https://liangdahong.com/2020/06/08/iOS%E4%B8%AD%E5%A6%82%E4%BD%95%E8%87%AA%E5%8A%A8%E7%9B%91%E6%8E%A7%E6%8E%A7%E5%88%B6%E5%99%A8%E5%86%85%E5%AD%98%E6%B3%84%E6%BC%8F/","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/liangdahong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-13T02:08:34.000Z","updated_at":"2025-06-08T16:03:14.000Z","dependencies_parsed_at":"2024-04-20T17:40:19.464Z","dependency_job_id":"43f93ac6-b63a-4bdb-aae4-11689f26f470","html_url":"https://github.com/liangdahong/AMLeaksFinder","commit_stats":{"total_commits":114,"total_committers":7,"mean_commits":"16.285714285714285","dds":"0.13157894736842102","last_synced_commit":"81a95eea27af0c886e033a5e71778ce1c7ccb4ba"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/liangdahong/AMLeaksFinder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liangdahong%2FAMLeaksFinder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liangdahong%2FAMLeaksFinder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liangdahong%2FAMLeaksFinder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liangdahong%2FAMLeaksFinder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liangdahong","download_url":"https://codeload.github.com/liangdahong/AMLeaksFinder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liangdahong%2FAMLeaksFinder/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265109673,"owners_count":23712730,"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":["controller","ios","leak","leaks","meaksfinder","memory","memory-leak","mleaksfinder","objective-c","runtime"],"created_at":"2024-11-22T08:29:28.216Z","updated_at":"2025-07-13T08:30:35.168Z","avatar_url":"https://github.com/liangdahong.png","language":"Objective-C","funding_links":[],"categories":["OOM-Leaks-Crash"],"sub_categories":["GraphQL"],"readme":"```js\n     _    __  __ _               _        _____ _           _\n    / \\  |  \\/  | |    ___  __ _| | _____|  ___(_)_ __   __| | ___ _ __\n   / _ \\ | |\\/| | |   / _ \\/ _` | |/ / __| |_  | | '_ \\ / _` |/ _ \\ '__|\n  / ___ \\| |  | | |__|  __/ (_| |   \u003c\\__ \\  _| | | | | | (_| |  __/ |\n /_/   \\_\\_|  |_|_____\\___|\\__,_|_|\\_\\___/_|   |_|_| |_|\\__,_|\\___|_|\n```\n\u003cp align=\"center\"\u003e\n\u003cimg  width=\"21.5%\" src=\"https://user-images.githubusercontent.com/12118567/137609767-23755a78-be8e-4310-99c9-bbb037d44bef.gif\"/\u003e\n\u003cimg  width=\"72.5%\" src=\"https://user-images.githubusercontent.com/12118567/89611994-4a904000-d8b1-11ea-8076-b3a754a9db49.png\"/\u003e\n\u003cp/\u003e\n\u003cp align=\"center\"\u003e\n\u003ca href=\"#\"\u003e\u003cimg src=\"https://img.shields.io/badge/platform-iOS-red.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"#\"\u003e\u003cimg src=\"https://img.shields.io/badge/support-iOS%209%2B%20-blue.svg?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/liangdahong/AMLeaksFinder/releases\"\u003e\u003cimg src=\"https://img.shields.io/cocoapods/v/AMLeaksFinder.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"#\"\u003e\u003cimg src=\"https://img.shields.io/badge/language-Objective--C-orange.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/liangdahong/AMLeaksFinder/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/licenses-MIT-red.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## 介绍\n\n本项目是一款用于自动检测 iOS 项目中【 **`UIView 和 UIViewController 内存泄漏`** 】的工具，只需 `pod 'AMLeaksFinder'` 即可 0 行代码实现自动监控，效果如下，推荐使用 `Cocoapods` 导入，和 [MLeakFinder](https://github.com/Tencent/MLeaksFinder) 的区别可参考 [对比 MLeakFinder](https://github.com/liangdahong/AMLeaksFinder/issues/4) 。\n\n[English 📔](README_EN.md)\n\n\n## 功能介绍\n\n* [x] 自动监控 **`Controller`** 的泄漏；\n* [x] 自动监控 **`View`** 的泄漏；\n* [x] 借助 [FBRetainCycleDetector](https://github.com/facebook/FBRetainCycleDetector) 快速排查泄漏原因 【 ⚠️ 只在 `ObjC` 上有效 】；\n* [x] 监控到泄漏时支持快速查看泄漏的视图【 **`View`**，**`Controller View`**，**`View 的 root View`** 等】；\n* [ ] 更多功能欢迎补充。\n\n## Cocoapods\n\n```\npod 'AMLeaksFinder', '2.2.8',  :configurations =\u003e ['Debug']\n```\n\n- 如果想查看控制器的强引用链，可导入：Facebook 的 [FBRetainCycleDetector](https://github.com/facebook/FBRetainCycleDetector) 框架即可。\n\n```\npod 'FBRetainCycleDetector', :git =\u003e 'https://github.com/facebook/FBRetainCycleDetector.git', :branch =\u003e 'main', :configurations =\u003e ['Debug']\n```\n\n## 直接使用\n\n- 请拖拽 `AMLeaksFinder/AMLeaksFinder` 文件夹的全部内容到项目\n\n\n- 启用 \u0026 关闭 `AMLeaksFinder`\n  -  打开 `__AUTO_MEMORY_LEAKS_FINDER_ENABLED__` 宏表示启用\n  -  注释 `__AUTO_MEMORY_LEAKS_FINDER_ENABLED__` 宏表示关闭\n  \n- 显示/隐藏 `AMLeaksFinder` 视图\n  - 发送通知\n    ```ObjectiveC\n    if (显示UI) {\n       [NSNotificationCenter.defaultCenter postNotificationName:@\"AMLeaksFinderShowUINotification\" object:nil];\n    } else {\n       [NSNotificationCenter.defaultCenter postNotificationName:@\"AMLeaksFinderHideUINotification\" object:nil];\n    }\n    ```\n    \n## 数据收集\n\u003e 若想收集泄漏相关数据可使用如下 API:\n- https://github.com/liangdahong/AMLeaksFinder/blob/master/AMLeaksFinder/AMLeaksFinder.h\n\n```\n控制器路径变化 AMLeaksFinder.ViewHasLeakVC viewDidDisappear: 2022-04-04 04:21:06 +0000\n控制器路径变化 AMHomeVC viewDidAppear: 2022-04-04 04:21:06 +0000\n控制器路径变化 AMPresentHasLeakVC viewDidLoad: 2022-04-04 04:21:07 +0000\n控制器路径变化 AMPresentHasLeakVC viewDidAppear: 2022-04-04 04:21:07 +0000\n控制器路径变化 AMTabBarController viewDidDisappear: 2022-04-04 04:21:07 +0000\n控制器路径变化 BMNavigationController viewDidDisappear: 2022-04-04 04:21:07 +0000\n控制器路径变化 AMHomeVC viewDidDisappear: 2022-04-04 04:21:07 +0000\n控制器路径变化 AMTabBarController viewDidAppear: 2022-04-04 04:21:08 +0000\n控制器路径变化 BMNavigationController viewDidAppear: 2022-04-04 04:21:08 +0000\n控制器路径变化 AMHomeVC viewDidAppear: 2022-04-04 04:21:08 +0000\n控制器路径变化 AMPresentHasLeakVC viewDidDisappear: 2022-04-04 04:21:08 +0000\n⚠️👇🏻\n视图泄漏: \u003cUIView: 0x7f9849a214d0; frame = (65 176; 294 348); autoresize = RM+BM; layer = \u003cCALayer: 0x60000090ed00\u003e\u003e \n视图所在控制器 AMLeaksFinder.ViewHasLeakVC \n操作路径:\nBMNavigationController(viewDidLoad:) -\u003e \nAMTabBarController(viewDidLoad:) -\u003e \nAMHomeVC(viewDidLoad:) -\u003e \nAMTabBarController(viewDidAppear:) -\u003e \nBMNavigationController(viewDidAppear:) -\u003e \nAMHomeVC(viewDidAppear:) -\u003e \nAMPresentHasLeakVC(viewDidLoad:) -\u003e \nAMPresentHasLeakVC(viewDidAppear:) -\u003e \nAMTabBarController(viewDidDisappear:) -\u003e \nBMNavigationController(viewDidDisappear:) -\u003e \nAMHomeVC(viewDidDisappear:) -\u003e \nAMTabBarController(viewDidAppear:) -\u003e \nBMNavigationController(viewDidAppear:) -\u003e \nAMHomeVC(viewDidAppear:) -\u003e \nAMPresentHasLeakVC(viewDidDisappear:) -\u003e \nAMPresentHasLeakVC(viewDidLoad:) -\u003e \nAMPresentHasLeakVC(viewDidAppear:) -\u003e \nAMTabBarController(viewDidDisappear:) -\u003e \nBMNavigationController(viewDidDisappear:) -\u003e \nAMHomeVC(viewDidDisappear:) -\u003e \nAMTabBarController(viewDidAppear:) -\u003e \nBMNavigationController(viewDidAppear:) -\u003e \nAMHomeVC(viewDidAppear:) -\u003e \nAMPresentHasLeakVC(viewDidDisappear:) -\u003e \n_UIAlertControllerTextFieldViewController(viewDidLoad:) -\u003e \nUIAlertController(viewDidLoad:) -\u003e \nUIAlertController(viewDidAppear:) -\u003e \nUIAlertController(viewDidDisappear:) -\u003e \nAMLeaksFinder.ViewHasLeakVC(viewDidLoad:) -\u003e \nAMHomeVC(viewDidDisappear:) -\u003e \nAMLeaksFinder.ViewHasLeakVC(viewDidAppear:) -\u003e \nAMLeaksFinder.ViewHasLeakVC(viewDidDisappear:) -\u003e \nAMHomeVC(viewDidAppear:) -\u003e \nAMPresentHasLeakVC(viewDidLoad:) -\u003e \nAMPresentHasLeakVC(viewDidAppear:) -\u003e \nAMTabBarController(viewDidDisappear:) -\u003e \nBMNavigationController(viewDidDisappear:) -\u003e \nAMHomeVC(viewDidDisappear:) -\u003e \nAMTabBarController(viewDidAppear:) -\u003e \nBMNavigationController(viewDidAppear:) -\u003e \nAMHomeVC(viewDidAppear:) -\u003e \nAMPresentHasLeakVC(viewDidDisappear:) -\u003e \n⚠️👆🏻\n```\n\n## 原理分析 \n\n- [原理分析](principle.md)\n- 数据结构图\n- ![数据结构图](https://user-images.githubusercontent.com/12118567/120919021-0bf22e80-c6ea-11eb-8f5f-d3d8c14d4666.jpg)\n\n- 项目文件结构\n```SWIFT\n├── AMLeaksFinder\n│   ├── AMLeaksFinder.h\n│   ├── AMLeaksFinder.m\n│   ├── AMLeaksFinder.bundle\n│   │   ├── all@2x.png\n│   │   ├── all@3x.png\n│   │   ├── leaks@2x.png\n│   │   └── leaks@3x.png\n│   ├── Objects\n│   │   ├── Controllers\n│   │   │   ├── Model\n│   │   │   │   ├── AMMemoryLeakDeallocModel.h\n│   │   │   │   ├── AMMemoryLeakDeallocModel.m\n│   │   │   │   ├── AMMemoryLeakModel.h\n│   │   │   │   └── AMMemoryLeakModel.m\n│   │   │   ├── NeedDealloc\n│   │   │   │   ├── UINavigationController+AMLeaksFinderSwizzleDealloc.m\n│   │   │   │   ├── UIPageViewController+AMLeaksFinderSwizzleDealloc.m\n│   │   │   │   ├── UISplitViewController+AMLeaksFinderSwizzleDealloc.m\n│   │   │   │   ├── UITabBarController+AMLeaksFinderSwizzleDealloc.m\n│   │   │   │   ├── UIViewController+AMLeaksFinderSwizzleDealloc.m\n│   │   │   │   ├── UIWindow+AMLeaksFinderSwizzleDealloc.m\n│   │   │   └── ViewDidLoad\n│   │   │       ├── UIViewController+AMLeaksFinderSwizzleViewDidLoad.m\n│   │   └── View\n│   │       └── Model\n│   │           ├── AMViewMemoryLeakDeallocModel.h\n│   │           ├── AMViewMemoryLeakDeallocModel.m\n│   │           ├── AMViewMemoryLeakModel.h\n│   │           └── AMViewMemoryLeakModel.m\n│   ├── UI\n│   │   ├── AMLeakDataModel.h\n│   │   ├── AMLeakDataModel.m\n│   │   ├── AMLeakOverviewView.h\n│   │   ├── AMLeakOverviewView.m\n│   │   ├── AMMemoryLeakView.h\n│   │   ├── AMMemoryLeakView.m\n│   │   ├── AMMemoryLeakView.xib\n│   │   ├── AMSnapedViewViewController.h\n│   │   ├── AMSnapedViewViewController.m\n│   │   ├── UIViewController+AMLeaksFinderUI.h\n│   │   └── UIViewController+AMLeaksFinderUI.m\n│   └── Uitis\n│       ├── Controller\n│       │   ├── UIViewController+AMLeaksFinderTools.h\n│       │   └── UIViewController+AMLeaksFinderTools.m\n│       └── View\n│           ├── UIView+AMLeaksFinderTools.h\n│           └── UIView+AMLeaksFinderTools.m\n```\n\n## 联系\n\n- 欢迎 [Issues](https://github.com/liangdahong/AMLeaksFinder/issues) 和 [Pull Requests](https://github.com/liangdahong/AMLeaksFinder/pulls)\n- 也可以添加微信\u003cimg width=\"20%\" src=\"https://user-images.githubusercontent.com/12118567/86319172-72fb9d80-bc66-11ea-8c6e-8127f9e5535f.jpg\"/\u003e 进群吹水。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliangdahong%2FAMLeaksFinder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliangdahong%2FAMLeaksFinder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliangdahong%2FAMLeaksFinder/lists"}