iOS之 FBMemoryProfiler FB的循环引用检测工具
2016-05-30 10:28
1096 查看
经过两天的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 install 估计是不能用啦,因为great wall
3·没什么问题那就到了使用阶段:
使用起来也是很方便的首先在main.m中添加如下代码
然后在appdelegate.m 中添加如下代码
还需要引入头文件
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![]()
相关文章推荐
- iOS 多线程篇1—多线程简单介绍
- iOS 笔试题
- iOS-TWRProgressView
- iOS 给TextView添加placeholder.
- GCD学习
- 简单的实用iOS运行时
- iOS_CoreText
- iOS中navigationItem的titleView如何居中
- IOS pod安装第三方库后不能在真机下编译,报错无法链接到第三方库
- iOS,一行代码进行RSA、DES 、AES、MD5加密、解密
- 一行代码实现iOS序列化与反序列化
- 【代码笔记】iOS-首页3张图片变化
- 【代码笔记】iOS-首页3张图片变化
- iOS 短信验证码倒计时按钮的实现
- iOS向右滑动返回上一界面
- ios - framework原理与详解
- 验证码倒计时按钮
- iOS动画解析
- iOS中的动画
- 正确使用iOS常量(const)、enum以及宏(#define)