iOS之 FBMemoryProfiler FB的循环引用检测工具
2024-10-19 11:52:10
经过两天的google终于搞定了FBMemoryProfiler这个开源检测循环引用的工具。中间的曲折也是让人头疼,言归正传直接说一下这个memoryProfiler
github:https://github.com/chengxiaoyu00/FBMemoryProfiler
1· 先介绍下这个开源工具:
An iOS library providing developer tools for browsing objects in memory over time, using FBAllocationTracker andFBRetainCycleDetector.
基于FBAllocationTracker and FBRetainCycleDetector 开发的一个检测iOS app内存的工具
2· 如何将工具集成到自己的工程:
现在github提供两种方法供开发者使用 :(Carthage 和CocoaPods)
这里我就拿pod说一下,Carthage可以自行google 因为用pod的人比较多集成起来也比较方便
只需要在你工程的podfile中添加:
pod 'FBMemoryProfiler'
然后执行
pod install --verbose --no-repo-update
pod install 估计是不能用啦,因为great wall
3·没什么问题那就到了使用阶段:
使用起来也是很方便的首先在main.m中添加如下代码
#import <FBAllocationTracker/FBAllocationTrackerManager.h> int main(int argc, char * argv[]) {
[[FBAllocationTrackerManager sharedManager] startTrackingAllocations];
[[FBAllocationTrackerManager sharedManager] enableGenerations];
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
然后在appdelegate.m 中添加如下代码
#if DEBUG
NSArray *filters = @[FBFilterBlockWithObjectIvarRelation([UIView class], @"_subviewCache"),
FBFilterBlockWithObjectIvarRelation([UIPanGestureRecognizer class], @"_internalActiveTouches")]; FBObjectGraphConfiguration *configuration =
[[FBObjectGraphConfiguration alloc] initWithFilterBlocks:filters
shouldInspectTimers:NO]; memoryProfiler = [[FBMemoryProfiler alloc] initWithPlugins:@[[CacheCleanerPlugin new],
[RetainCycleLoggerPlugin new]]
retainCycleDetectorConfiguration:configuration];
[memoryProfiler enable];
#endif
还需要引入头文件
#if DEBUG
#import <FBMemoryProfiler/FBMemoryProfiler.h>
#import <FBRetainCycleDetector/FBRetainCycleDetector.h>
#import "CacheCleanerPlugin.h"
#import "RetainCycleLoggerPlugin.h"
#endif
CacheCleanerPlugin.h和
RetainCycleLoggerPlugin.h
我会在下面附带下载地址
好了到目前为止已经可以使用这个工具了具体工具的功能很多大家可以自行开发理解,fb的东西还是良心之作的
这里强调下我的pod版本是最新的,而且你的podfile文件最好按照现在的标准去创建不然可能会提示你pod search 不到FBMenoryProfiler 、 还有这个工具支持版本不能低于8.0 ,到时候启动不了提示你 :dyld: Library not loaded: @rpath/FBAllocationTracker.framework/FBAllocationTracker
Referenced from: / 别怕google一下,具体答案自己去找一下很好改!
下面来一个jif
最新文章
- java ExecutorService
- iOS 生命周期
- div高度自适应(总结:min-height:100px; height:auto;的用法)
- 一步一步实战扩展 ASP.NET Route,实现小写 URL、个性化 URL
- Jquery动画效果--地铁站名指示等效果
- sharepoint 删除list里的所有内容
- N对括号的合法组合
- Web API (一)
- JS-监听文本回车事件写入数据表单
- JavaSE面试题收集【仅有题目,答案自备】
- SpringCloud(4)---Ribbon服务调用,源码分析
- 读书笔记---<;<;图解HTTP>;>;(一)
- [转]The Production Environment at Google
- Mini-Batch 、Momentum、Adam算法的实现
- perl5
- Python【知识点】面试小点列表生成式小坑
- [转]C# 理解lock
- VS2017+CMake+OpenCV下报错 set OpenCV_FOUND to FALSE
- 去掉C#中Guid.NewGuid().ToString()自动生成的短横线
- NGINX conf 配置文件中的变量大全 可用变量列表及说明
热门文章
- SQL Server - 把星期一(周一)当作每个星期的开始在一年中求取周数
- Entity Framework 实体框架的形成之旅--基于泛型的仓储模式的实体框架(1)
- 【工具】清理Windows Installer冗余文件(支持64位NT6.x系统)
- iOS 阶段学习第24天笔记(Block的介绍)
- autofac 使用
- 【Linux_Fedora_应用系列】_2_如何安装视频播放器和视频文件解码
- 通过angularjs的directive以及service来实现的列表页加载排序分页
- java集合-LinkedList
- 【前端福利】用grunt搭建自动化的web前端开发环境-完整教程
- 详细讲解nodejs中使用socket的私聊的方式