{"id":13387624,"url":"https://github.com/tencent/oomdetector","last_synced_at":"2026-01-30T14:36:51.108Z","repository":{"id":41883710,"uuid":"115068418","full_name":"Tencent/OOMDetector","owner":"Tencent","description":"OOMDetector is a memory monitoring component for iOS which provides you with OOM monitoring, memory allocation monitoring, memory leak detection and other functions.","archived":false,"fork":false,"pushed_at":"2023-02-21T02:31:59.000Z","size":7921,"stargazers_count":2321,"open_issues_count":37,"forks_count":356,"subscribers_count":65,"default_branch":"master","last_synced_at":"2025-03-03T08:17:09.959Z","etag":null,"topics":["ios","leak","oom"],"latest_commit_sha":null,"homepage":"","language":"Objective-C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tencent.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}},"created_at":"2017-12-22T02:37:52.000Z","updated_at":"2025-02-22T14:32:16.000Z","dependencies_parsed_at":"2022-08-11T20:01:17.518Z","dependency_job_id":"afdb90aa-f8fb-414e-be6a-c0afbffce926","html_url":"https://github.com/Tencent/OOMDetector","commit_stats":{"total_commits":56,"total_committers":7,"mean_commits":8.0,"dds":0.4821428571428571,"last_synced_commit":"1ce956775fefbf940df0fea28e334e47b8eb53e7"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2FOOMDetector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2FOOMDetector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2FOOMDetector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2FOOMDetector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tencent","download_url":"https://codeload.github.com/Tencent/OOMDetector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245474780,"owners_count":20621468,"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":["ios","leak","oom"],"created_at":"2024-07-30T12:01:25.343Z","updated_at":"2026-01-30T14:36:51.097Z","avatar_url":"https://github.com/Tencent.png","language":"Objective-C++","funding_links":[],"categories":["\u003ca id=\"58cd9084afafd3cd293564c1d615dd7f\"\u003e\u003c/a\u003e工具"],"sub_categories":["\u003ca id=\"d0108e91e6863289f89084ff09df39d0\"\u003e\u003c/a\u003e新添加的"],"readme":"\n## 简介\nOOMDetector是一个iOS内存监控组件，应用此组件可以帮助你轻松实现OOM监控、大内存分配监控、内存泄漏检测等功能。\n\n## 特性\n\n- 1.OOM监控：监控OOM，Dump引起爆内存的堆栈\n- 2.大内存分配监控：监控单次大块内存分配，提供分配堆栈信息\n- 3.内存泄漏检测：可检测OC对象、Malloc堆内存泄漏，提供泄漏堆栈信息\n\n## 演示\n![demo_gif](assets/oomgif.gif)\n\n## 支持CocoaPods\n\n在Podfile中添加如下文本\n\n```\n  pod 'OOMDetector', '1.3'\n```\n\n然后在命令行中运行\n```\n  pod install\n```\n需要注意的是OOMDetector使用了fishhook （0.2）\n如果你的工程中也使用了fishhook，建议移除，并统一使用CocoaPods管理\n\n```\n  pod 'fishhook', '0.2'\n```\n\n## 堆栈翻译\n\n```\n  translate_oom.py dsym_file oom_file\n```\ndsym_file\tapp的符号表路径，如OOMDetector.app.dSYM\n\noom_file \tLibrary/OOMDetector路径下的爆内存日志，如normal_malloc20180125_211259558.log\n\n## 使用方法\n### 初始化\n// 初始化，6s以下机型内存触顶阈值默认设置为300M，6s及以上机型内存触顶阈值默认设置为800M。\n\n\\- (void)setupWithDefaultConfig;\n### OOM监控\n// 开启OOM监控，默认在setupWithDefaultConfig方法中已经开启  \n\n\\-(void)startMaxMemoryStatistic:(double)overFlowLimit;\n### 大内存分配监控\n// 开启单次大内存分配监控\n\n\\-(BOOL)startSingleChunkMallocDetector:(size_t)threshholdInBytes callback:(ChunkMallocBlock)callback;\n### 内存泄漏检测\n\n// 初始化内存泄漏监控器，记录所有堆对象\n\n\\- (void)setupLeakChecker;\n    \n// 执行一次泄露检测，建议在主线程调用，该操作会挂起所有子线程进行泄露检测（该操作较耗时，平均耗时在1s以上，请限制调用频率）\n\n\\-(void)executeLeakCheck:(QQLeakCheckCallback)callback;\n    \n### 其它功能\n\n// 开启堆内存堆栈监控，开启后会实时记录所有的内存分配堆栈，并将多次重复调用的相同堆栈合并，如果合并后的size大于threshHoldInbytes，该分配堆栈将被输出到log用于分析，log路径Library/OOMDetector\n\n\\-(BOOL)startMallocStackMonitor:(size_t)threshholdInBytes needAutoDumpWhenOverflow:(BOOL)needAutoDump dumpLimit:(double)dumpLimit sampleInterval:(NSTimeInterval)sampleInterval;\n    \n// 开启VMStackMonitor用以监控非直接通过malloc方式分配的内存因为startVMStackMonitor:方法用到了私有API __syscall_logger会带来app store审核不通过的风险，此方法默认只在DEBUG模式下生效，如果需要在RELEASE模式下也可用，请打开USE_VM_LOGGER_FORCEDLY宏，但是切记在提交appstore前将此宏关闭，否则可能会审核不通过\n\n\\-(BOOL)startVMStackMonitor:(size_t)threshHoldInbytes;\n    \n### 设置代理\n\n@protocol QQOOMPerformanceDataDelegate \u003cNSObject\u003e\n// 在调用startMaxMemoryStatistic:开启内存触顶监控后会触发此回调，返回前一次app运行时单次生命周期内的最大物理内存数据\n    \n\\-(void)performanceData:(NSDictionary *)data completionHandler:(void (^)(BOOL))completionHandler;\n@end\n    \n@protocol QQOOMFileDataDelegate \u003cNSObject\u003e\n// 在出现单次大块内存分配、检查到内存泄漏且时、调用uploadAllStack方法时触发此回调\n    \n\\-(void)fileData:(NSData *)data extra:(NSDictionary\u003cNSString *,NSString *\u003e *)extra type:(QQStackReportType)type completionHandler:(void (^)(BOOL))completionHandler;\n@end\n\n## PS\n如果你遇到类似\"Undefined symbols for architecture arm64:\n  \"std::__1::__next_prime(unsigned long)\"\"的链接问题, 你可以做如下设置:\n  \nBuild Settings -\u003e Linking -\u003e Other Linker Flags -\u003e -lc++\n\n## 变更记录\n暂无\n## 帮助\n暂无\n## 许可证\nOOMDetector适用MIT协议，详见[LICENSE](/LICENSE)。\n\n\n\n****\n\n## Introduction\n\nOOMDetector is a memory monitoring component for iOS which provides you with OOM monitoring, memory allocation monitoring, memory leak detection and other functions.\n\n## Features\n- OOM Monitoring  : Monitoring OOM then dump stacks which cause OOM problems.\n- Large Memory Allocation Monitoring  : Monitoring large memory allocation then provides memory allocation stacks for you.\n- Memory Leak Detecting  : Detecting memory leak for both OC objects and c heap memory then provides memory allocation stacks for you.\n\n\n## Demo\n![demo_gif](assets/oomgif.gif)\n\n## Usage\n\n\n### Initialization\n// 初始化，6s以下机型内存触顶阈值默认设置为300M，6s及以上机型内存触顶阈值默认设置为800M。\n\n\\- (void)setupWithDefaultConfig;\n### OOM Monitoring\n// 开启OOM监控，默认在setupWithDefaultConfig方法中已经开启\n\n\\-(void)startMaxMemoryStatistic:(double)overFlowLimit;\n### Large Memory Allocation Monitoring\n// 开启单次大内存分配监控\n\n\\-(BOOL)startSingleChunkMallocDetector:(size_t)threshholdInBytes callback:(ChunkMallocBlock)callback;\n### Memory Leak Detecting\n\n// 初始化内存泄漏监控器，记录所有堆对象\n\n\\- (void)setupLeakChecker;\n    \n// 执行一次泄露检测，建议在主线程调用，该操作会挂起所有子线程进行泄露检测（该操作较耗时，平均耗时在1s以上，请限制调用频率）\n\n\\-(void)executeLeakCheck:(QQLeakCheckCallback)callback;\n\n### Other Functions\n\n// 开启堆内存堆栈监控，开启后会实时记录所有的内存分配堆栈，并将多次重复调用的相同堆栈合并，如果合并后的size大于threshHoldInbytes，该分配堆栈将被输出到log用于分析，log路径Library/OOMDetector\n\n\\-(BOOL)startMallocStackMonitor:(size_t)threshholdInBytes needAutoDumpWhenOverflow:(BOOL)needAutoDump dumpLimit:(double)dumpLimit sampleInterval:(NSTimeInterval)sampleInterval;\n    \n// 开启VMStackMonitor用以监控非直接通过malloc方式分配的内存因为startVMStackMonitor:方法用到了私有API __syscall_logger会带来app store审核不通过的风险，此方法默认只在DEBUG模式下生效，如果需要在RELEASE模式下也可用，请打开USE_VM_LOGGER_FORCEDLY宏，但是切记在提交appstore前将此宏关闭，否则可能会审核不通过\n\n\\-(BOOL)startVMStackMonitor:(size_t)threshHoldInbytes;\n    \n### Delegate\n\n@protocol QQOOMPerformanceDataDelegate \u003cNSObject\u003e\n// 在调用startMaxMemoryStatistic:开启内存触顶监控后会触发此回调，返回前一次app运行时单次生命周期内的最大物理内存数据\n    \n\\-(void)performanceData:(NSDictionary *)data completionHandler:(void (^)(BOOL))completionHandler;\n@end\n    \n@protocol QQOOMFileDataDelegate \u003cNSObject\u003e\n// 在出现单次大块内存分配、检查到内存泄漏且时、调用uploadAllStack方法时触发此回调\n    \n\\-(void)fileData:(NSData *)data extra:(NSDictionary\u003cNSString *,NSString *\u003e *)extra type:(QQStackReportType)type completionHandler:(void (^)(BOOL))completionHandler;\n@end\n\n## PS\nIf you come across link errors like \"Undefined symbols for architecture arm64:\n  \"std::__1::__next_prime(unsigned long)\"\", do as follows:\n  \nBuild Settings -\u003e Linking -\u003e Other Linker Flags -\u003e -lc++\n\n\n## Known Issues\n\n### Conflict with fishhook\n现在已知Podfile中有FBRetainCycleDetector时会有编译错误，原因是FBRetainCycleDetector中包含了fishhook，目前遇到这种情况，请先移除FBRetainCycleDetector，然后再pod install试试\n\n## Changes Log\n\n## Help\n\n## License\nOOMDetector is under the MIT license. See the [LICENSE](/LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftencent%2Foomdetector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftencent%2Foomdetector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftencent%2Foomdetector/lists"}